Simple and usefull monit conf for elasticsearch
Getting your elasticsearch cluster running is not so long. But now you have to properly monitor it.
It can be down even if the server is still up and even the “java elasticsearch process”.
Here is a nice monit conf grab from chef elasticsearch cookbook:
1 2 3 4 5 6 7 8 9 10 |
check host elasticsearch_connection with address 0.0.0.0 if failed url http://0.0.0.0:9200/ with timeout 15 seconds then alert group elasticsearch check host elasticsearch_cluster_health with address 0.0.0.0 if failed url http://0.0.0.0:9200/_cluster/health and content == 'green' with timeout 60 seconds then alert group elasticsearch |
Will send a mail if the http api not reply and the last but not least will send a mail if the cluster is in another state than green (this is the beggining of the end sometimes ;) ).
You have to install this on each node.
In my case i run all my node with monit (ping me if you want a 30 seconds monit install on debian like).
hi!
I’ve tried this code but Monit complaints about regular expresion, any thoughts? The first logic works ok but the second fails :S
[CEST Apr 27 12:25:05] error : ‘elasticsearch_cluster_health’ failed protocol test [HTTP] at INET[localhost:9200/_cluster/health] via TCP — HTTP error: Regular expression doesn’t match: No match
Thanks anyway!
Fixed that code for my purposes:
check host elasticsearch_connection with address 127.0.0.1
start program = “/usr/bin/env service elasticsearch start”
stop program = “/usr/bin/env service elasticsearch stop”
if failed url http://127.0.0.1:9200/ with timeout 15 seconds then restart
group elasticsearch
Thank you very much Dmitry.
How can we alert the same to a hipchat room?
Yes. You need to use the hipchat api and and a custom alert script in monit. Use “then exec myscript.sh” in monit.