I am using logstash http poller plugin to call an API to retrieve information. Below is my logstash conf.
input {
http_poller {
urls => {
test2 => {
method => get
url => "http://localhost:9000/api/measures/component
headers => {
Accept => "application/json"
}
}
}
request_timeout => 60
# Supports "cron", "every", "at" and "in" schedules by rufus scheduler
schedule => { cron => "* * * * * UTC"}
codec => "json"
# A hash of request metadata info (timing, response headers, etc.) will be sent here
metadata_target => "http_poller_metadata"
}
}
output {
elasticsearch { hosts => ["localhost:9200"] }
stdout { codec => rubydebug }
}
The rubydebug output is below:
{
"measures" => [
[0] {
"periods" => [
[0] {
"index" => 1,
"value" => "-4"
}
],
"value" => "24",
"metric" => "ncloc"
}
]
}
How do i parse the values in the json to key/value fields in the elasticsearch fields?
for example.
measures.value = 24
measures.metric = ncloc