Logstash exec input plugin empty message

Hi, i'm trying to use logstash exec input plugin to run a shell script, however i'm not getting any result.

i have a sample shell script
/scripts/myscript.sh
the contents is just
ls

if i start logstash with the following configuration:
input {
exec {
command => "/script/myscript.sh"
interval => 60
type => "test"
}
}
output {
stdout { codec => rubydebug }
elasticsearch { hosts => ["localhost:9200"]
index => "myindex-%{[type]}-%{+YYYY.MM.dd}"
}
}

then the message is empty, however if i start with:
input {
exec {
command => "ls"
interval => 60
type => "test"
}
}
output {
stdout { codec => rubydebug }
elasticsearch { hosts => ["localhost:9200"]
index => "myindex-%{[type]}-%{+YYYY.MM.dd}"
}
}

then message has the output of ls.
Why are shell scripts not running or not returning what they should?
This is just a simple test, in my case i need to put more logic on the shell script, if it would be simple would just use the second option.

Any idea?

Is /script/myscript.sh executable? Are there any errors in the logstash logs?

Yes of course

finally i made it to work, had to change line
command => "/script/myscript.sh"

to

command => "sh -c /script/myscript.sh"

Dont know it thats the way it should be used, but it worked.

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