Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP output in Logstash with JSON

Tags:

logstash

In Logstash, when a log of a certain time is processed, I want Logstash to do an HTTP POST to a webserver, sending JSON. However, it's giving me errors and won't start logstsh. I'm assuming it doesn't like the ' around the JSON data that is part of the message. FOOIP is a variable with the IP Address found in the Log. Any help would be great

Logstash config file....

output{
    if [type]=="FOO"{
       http {
       format=>"json"
       http_method=>"post"
       url=>"http://192.168.1.10/bar"
       message=>"{'target':{'IPAddress':'"%{FOOIP}"},'commandName':'Test'}"
    }
}
like image 464
cybergoof Avatar asked Jul 23 '14 20:07

cybergoof


1 Answers

The http output when format is set to json will post the whole event in json to the web service (so it will ignore the message piece you have set). So if you want it to work with the exact message that you are setting, try changing to format=message.

like image 73
Alcanzar Avatar answered Sep 18 '22 14:09

Alcanzar