Http_poller input

Hi ,
i want to receive data through HTTP requests using logstash.
my file.conf look like this :
input {
http_poller {
urls => {
url => "http://api.v4.boosterbc.net/suggest/cities?term=hamma&lang=fr "
}
request_timeout => 60
schedule => { every => "20s"}
codec => "line"
}

}
output {
elasticsearch {
hosts => "localhost:9200"
index => "contacts"
}
stdout { codec => rubydebug }
}

But logstash terminates without giving any result.
any help please !

The Logstash logs say there's a syntax error.

Is your file valid/encoded correctly on Windows?
Please check is UTF-8 encoded (e.g. use Notepad++).

I've tested the following and it works:

input {
	http_poller {
		urls => {
			url => "http://api.v4.boosterbc.net/suggest/cities?term=hamma&lang=fr"
		}
		request_timeout => 60
		schedule => { every => "20s" }
		codec => "line"
	}
}
output {
	elasticsearch {
		hosts => "localhost:9200"
		index => "contacts"
	}
	stdout { codec => rubydebug }
}

A comment: the response of the API you're targeting is JSON.
You can use codec => json to convert it into a valid structured JSON document (and it will be indexed as such).

it works .
Thank you

1 Like

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