# Monit + logstash

**URL:** <https://discuss.elastic.co/t/monit-logstash/64553>\
**Category:** Logstash\
**Created:** [November 1, 2016, 12:06pm UTC](https://discuss.elastic.co/t/monit-logstash/64553 "2016-11-01T12:06:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rashthedude](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rashthedude](https://discuss.elastic.co/u/rashthedude)\
**Post date:** [November 1, 2016, 12:06pm UTC](https://discuss.elastic.co/t/monit-logstash/64553/1 "2016-11-01T12:06:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 1, 2016, 12:12pm UTC](https://discuss.elastic.co/t/monit-logstash/64553/2 "2016-11-01T12:12:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rashthedude](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rashthedude](https://discuss.elastic.co/u/rashthedude)\
**Post date:** [November 1, 2016, 12:19pm UTC](https://discuss.elastic.co/t/monit-logstash/64553/3 "2016-11-01T12:19:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![teebu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teebu/32/10119_2.png) [@teebu](https://discuss.elastic.co/u/teebu)\
**Post date:** [November 30, 2016, 9:32pm UTC](https://discuss.elastic.co/t/monit-logstash/64553/4 "2016-11-30T21:32:44Z")

</div>

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.

```auto
# 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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:30am UTC](https://discuss.elastic.co/t/monit-logstash/64553/5 "2017-07-06T04:30:06Z")

</div>


