Using request_path to create output filter?

Hello,
I'm using the following configuration to route request to my Elastic Instance. However, it looks like the request_path header IF check is not passing and thus the elasticsearch instance is not being invoked. Can we not use the request headers to create such configurations?

curl -H "content-type: application/json" -XPUT 'http://10.222.51.58:8080/aws-metrics' --data '@/C/Users/Temp/Desktop/my-file.json'

output {
	stdout { 
		codec => rubydebug
	} 
    if[request_path] == "/aws-metrics" {
		elasticsearch {
			hosts => ["https://elasticsearch.myhost.com:443/"]
			index => "myapp-ls-%{+YYYY.MM.dd}"
			user => "elastic"
			password => "elastic"
		}
	}
}

Logstash stdout

{
....
"headers" => {
            "http_accept" => "*/*",
           "content_type" => "application/json",
           "request_path" => "/aws-metrics",
           "http_version" => "HTTP/1.1",
        "http_connection" => "Keep-Alive",
         "request_method" => "PUT",
              "http_host" => "10.222.51.58:8080",
            "request_uri" => "/aws-metrics",
         "content_length" => "3177",
            "http_expect" => "100-continue",
        "http_user_agent" => "curl/7.56.1"
    },
    "MyMetric" : "123",
    "MyMEtric2" : "1222".
    .....
}

That should be

if [headers][request_path] == "/aws-metrics" {
1 Like

Perfect. Thanks!

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