Pass access token received from http_poller call to http filter

I am able to successfully get an access token from the http_poller plugin but now I need to pass that token on to the http filter in order to make my REST call.

I'm assuming that I need to do this through the headers field in the http filter such as

headers => ["Authorization", "Bearer xxxx-token from http_poller"] but not sure how to this dynamically so that it uses the token from the http_poller plugin.

New to these two plugins so any help / direction is greatly appreciated.

My access token is being returned in the access_token field from the http_poller plugin and my http filter is configured like this

		http {
			body_format => "json"
			follow_redirects => false
			body => {
				"attribute" => "%{[attribute_value]}"
			}
			url => REST API URL
			verb => "GET"
			headers => [ "Authorization", "Bearer %{access_token}" ]
			target_body => "[@metadata][api_response]"
			target_headers => "[@metadata][api_headers]" 
		}

Pretty sure that I have the 'headers' section set up wrong but was trying to get a starting point.

Thanks,
Bill

haven’t had experience with this, but the docs said that headers should be hash so have you tried

headers => {
  “Authorization” => “Bearer %{access_token}”
}

This worked like a charm - thank you

Now I'm on to seeing why my metric data is being injected into the target_body field and I think it has something to do with this - I think it's set incorrectly

target_body => "[@metadata][api_response]"

Thanks,
Bill

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