Hey everyone,
for testcases I am requesting some urls and want to send the result to my elasticsearch. this is my config file:
input {
http_poller {
urls => {
"service1" => "http://192.168.99.100:9200/services/external/1"
"service2" => "http://192.168.99.100:9200/services/external/2"
"service3" => "http://192.168.99.100:9200/services/external/3"
"service4" => "http://192.168.99.100:9200/services/external/4"
"service5" => "http://192.168.99.100:9200/services/external/5"
}
automatic_retries => 0
codec => "json"
interval => 10
request_timeout => 8
metadata_target => http_poller_metadata
tags => service_healthcheck
}
}
filter {
if [http_poller_metadata] {
mutate {
add_field => {
"@name" => "%{http_poller_metadata[name]}"
"@state" => "%{http_poller_metadata[state]}"
}
}
}
}
output {
elasticsearch {
hosts => ["localhost"]
}
stdout {
codec => rubydebug
}
}
And this is what the json behind the url looks like
_index "services"
_type "external"
_id "1"
_version 4
found true
_source
doc
name "Service-1"
state "up"
I am getting results in the console, so something works.
Console:
{
"@state" => "%{http_poller_metadata[state]}",
"@name" => "service1",
"found" => true,
"@timestamp" => 2017-09-15T11:11:06.682Z,
"_index" => "services",
"_type" => "external",
"@version" => "1",
"http_poller_metadata" => {
"request" => {
"method" => "get",
"url" => "http://192.168.99.100:9200/services/external/1"
},
"response_headers" => {
"transfer-encoding" => "chunked",
"content-type" => "application/json; charset=UTF-8"
},
"code" => 200,
"response_message" => "OK",
"times_retried" => 0,
"runtime_seconds" => 0.005,
"name" => "service1",
"host" => "4bf19441e414"
},
"_source" => {
"doc" => {
"name" => "Service-1",
"state" => "up"
}
},
"_id" => "1",
"_version" => 4,
"tags" => [
[0] "service_healthcheck"
]
}
But the @name and @state field are not filled with the correct values, and nothing is transfered into elasticsearch (I see no changes in Kibana after starting).
Any suggestions?