Http_poller run ruby script and use some vars in the header

I want to retrieve logs from a server using http_poller plugin but I need to set some vars in the header request. Then, I need to execute the ruby code and use the vars in the input of conf file

**api_key** = '27c59....beb28'
api_secret = '15db2.....b682ec'
**data** = 'thedata'
**timestamp** = DateTime.now.strftime('%s')
text_to_hash = api_key <<  data << String(timestamp)
digest = OpenSSL::Digest.new('SHA256')
**hash** = OpenSSL::HMAC.hexdigest(digest, api_secret, text_to_hash)

conf File

input {
    http_poller {
        urls => {
          api2 => {
            url => "the_endpoint"
            method => post
            headers => {
              "Content-Type" => "application/json"
              "x-ltd-apikey" => <**api_key**>
              "x-ltd-sign" => <**hash**>
              "x-ltd-timestamp" => <**timestamp**>
            }
            body => <**data**>
          }
        }
        schedule => {
          "in" => "1s"
        }
      }
}

Do you have some idea?

I am not aware of any way to run ruby (essentially a filter) before running an input.

If you need to do something in ruby to build the apikey and signed data then you would have to implement the POST in the ruby filter too. You could probably still use the http_poller just for the scheduling, or perhaps replace it with a heartbeat input.

Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.