Monit + logstash

Hi there,

I'm having a difficult time trying to monitor Logstash using monit. All I want to do is check if Logstash is either up/down and if it's processing requests. Can anyone point to me to a direction here?

Regards,
Rashid

Logstash 5.0 introduces monitoring APIs would be very useful here. For earlier versions it's... trickier.

thanks @magnusbaeck. So upgrading is the preferred way here I guess.

I'm still using LS1.5

Using the heartbeat output plugin and then using monit to check the timestamp to see if its running.

I ran into some file read/write permission errors, so I had to manually chmod the output file.

# setup log file for monit to make sure logstash is still running
input {
  heartbeat {
    message => "sequence"
    interval => 60
    type => "heartbeat"
  }
}

output {
  if [type] == "heartbeat" {
    #stdout {codec => rubydebug }
    file {
        #sudo chmod 777 /var/log/logstash/logstash-heartbeat.log (so monit can read it)
        path => "/var/log/logstash/logstash-heartbeat.log"
    }
  }
}

monit config script:

check process logstash with pidfile /var/run/logstash.pid
  start program = "/etc/init.d/logstash start"
  stop  program = "/etc/init.d/logstash stop"
check file logstash-heartbeat.log with path /var/log/logstash/logstash-heartbeat.log
  if timestamp > 10 minutes then restart