elasticsearchlogstashlogstash-configurationelasticsearch-x-pack

How to provide api token based authentication to Logstash http input


I'm have this simple logstash config, and I would like to add api-token auth to http input. I know how to do that for output to elastic search, but can't figure out is that possible to provide similar to http input

input {
    http {
        host => "0.0.0.0"
        port => 8080 # default: 8080
        ssl => false
    }
}

output {
    stdout {
        
    }
    elasticsearch {
        hosts => "elasticsearch:9200"
        api_key => "my_api_key"
        index => "my-local-index"
    }
}

Ideal request would be like

curl -d '{"message": "my log"}' -H 'Content-Type: application/json' -H 'Authorization: ApiKey my_api_key' http://localhost:8080

Solution

  • The http input creates an http server socket. That can support basic authorization using the user and password options for the input. It does not support using an elasticsearch API key.