Consul alerts comes really handy in order to notify you whenever the services that you are monitoring goes down. There are many channels that we could integrate. In this blog, I’ll be using HipChat.
To set up:
- Install consul alerts
/usr/local/go/bin/go get -u github.com/AcalephStorage/consul-alerts
- Set the HipChat keys. We could do this via :
- Key/Value on Consul UI
2. Ansible Consul module for Ansible version >= 2.0
– name: set consul HipChat enable key
consul_kv:
key: consul-alerts/config/notifiers/hipchat/enabled
value: true
when: ansible_version.major|int>=2.0
- Create a Start script in /etc/init/consul-alert.conf
description “Consul alert process”
start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]respawn
setuid consul
setgid consulexec /opt/alert/bin/./consul-alerts start –alert-addr=localhost:9000 –consul-addr=localhost:8500 –consul-dc=dev –consul-acl-token=”” –watch-events –watch-checks –log-level=err
To use Ansible consul module, you will need to install the module:
– name: install ansible consul module
pip:
name: python-consul
state: present
- Start service
service consul-alert start