Cannot add custom headers to http poll input in logstash

I know this post is kind of old but I was facing the same problem until I realized that for some reason I had to wrap the other headers between quotes, although the Accept header don't seem to need them.

This configuration yields syntax errors in /var/log/logstash/logstash-plain.log

input{
    http_poller{
        urls => {
            myurl => {
                url => "https://server:port/"
                headers => {
                    Accept => "application/json"
                    Content-Type => "application/json"
                }
            }
...
}

This configuration works perfectly. Note the double quotes in Content-type header.

input{
    http_poller{
        urls => {
            myurl => {
                url => "https://server:port/"
                headers => {
                    Accept => "application/json"
                    "Content-Type" => "application/json"
                }
            }
...
}

Hope this helps other people.

4 Likes