Hi,
I am trying to POST data to a REST API and get the response back in logstash and output it to elastic.
What is the syntax to POST data ? Is this correct ?
http_poller {
urls => {
url1 => {
method => "POST"
url => ""
add_field => {
username => "username"
password => "password"
}
}
}
request_timeout => 30
interval => 120
codec => json
metadata_target => "http_poller_metadata"
}
I want to post, {"username":"username_val","password":"password_val"} as a JSON to an API.
Logstash http_poller input supports any Manticore Client options.
Example:
input {
# To improve performance, search only today and yesterday's index
# Percent Encoded: "<.monitoring-es-2-{now%2Fd}>,<.monitoring-es-2-{now-1d}>/_search"
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html
http_poller {
urls => {
my_es_cluster => {
method => post
url => "http://localhost:9200/%3C.monitoring-es-2-%7Bnow%2Fd%7D%3E,%3C.monitoring-es-2-%7Bnow-1d%7D%3E/_search"
body => '{ "query": { "range": { "timestamp": { "gt": "now-1h" } } } }'
headers => {
Accept => "application/json"
}
auth => {
user => "elastic"
password => "changeme"
}
}
}
request_timeout => 60
interval => 60
}
}
output {
stdout { codec => rubydebug }
}
3 Likes