lovebeat
lovebeat copied to clipboard
Docker container does not trigger script
I use the script from the documentation (located in /var/www/lovebeat.sh):
#!/bin/bash
echo "Hello World"
env
And this config file (located in /var/www/lovebeat.sh):
[[alarms]]
name = "beatstash"
pattern = "beatstash.*"
[[alarms.alerts]]
script = "/var/www/lovebeat.sh"
Along with this docker command:
docker run --rm -it -p 8127:8127/udp -p 8127:8127/tcp -p 8082:8080 -v /etc/lovebeat.cfg:/etc/lovebeat.cfg -v /var/log/lovebeat:/var/log/lovebeat/ -v /var/www/lovebeat.sh:/var/www/lovebeat.sh boivie/lovebeat
And then when I send some events with an error timeout of 1 second, the script is not called:
$ docker run --rm -it -p 8127:8127/udp -p 8127:8127/tcp -p 8082:8080 -v /etc/lovebeat.cfg:/etc/lovebeat.cfg -v /var/log/lovebeat:/var/log/lovebeat/ -v /var/www/lovebeat.sh:/var/www/lovebeat.sh boivie/lovebeat
2016/07/12 13:22:05 INFO Lovebeat v0.8.0 started as host aa61fa6cfefe, PID 1, running from /data
2016/07/12 13:22:05 INFO Reading configuration file /etc/lovebeat.cfg
2016/07/12 13:22:05 INFO No metrics reporting configured
2016/07/12 13:22:05 ERROR Couldn't open 'lovebeat.db'
2016/07/12 13:22:05 INFO Created view 'all' (''), state = paused
2016/07/12 13:22:05 INFO VIEW 'all', 0: state paused -> ok
2016/07/12 13:22:05 INFO HTTP listening on :8080
2016/07/12 13:22:05 INFO UDP listening on :8127
2016/07/12 13:22:05 INFO TCP listening on :8127
2016/07/12 13:23:07 INFO SERVICE 'beatstash.heartbeat', state paused -> ok
2016/07/12 13:23:07 INFO SERVICE 'beatstash.heartbeat', err -1 -> 1000
2016/07/12 13:23:08 INFO SERVICE 'beatstash.heartbeat', state ok -> error
2016/07/12 13:23:08 INFO VIEW 'all', 1: state ok -> error
2016/07/12 13:23:32 INFO SERVICE 'beatstash.heartbeat', state error -> ok
2016/07/12 13:23:32 INFO VIEW 'all', 1: state error -> ok
2016/07/12 13:23:34 INFO SERVICE 'beatstash.heartbeat', state ok -> error
2016/07/12 13:23:34 INFO VIEW 'all', 2: state ok -> error
Logs from event-sender terminal (on the same machine):
$ curl -X POST -H 'application/x-www-form-urlencoded' 'http://localhost:8082/api/services/beatstash.heartbeat?err-tmo=1'
{}
$ # sleep 5 seconds
$ curl -X POST -H 'application/x-www-form-urlencoded' 'http://localhost:8082/api/services/beatstash.heartbeat?err-tmo=1'
{}
According to the documentation I should see something like this in the output logs:
2016/01/26 18:10:56 INFO ALARM 'example', 11: state ok -> error
2016/01/26 18:10:56 INFO Running alert script /path/to/script.sh
Hello World
LOVEBEAT_ALARM=example
LOVEBEAT_STATE=ERROR
LOVEBEAT_PREVIOUS_STATE=OK
LOVEBEAT_INCIDENT=11
But it's not the case.
I also checked script permissions and it's 0777 for now :
$ ls -la /var/www/lovebeat.sh
-rwxrwxrwx 1 root root 35 Jul 12 14:25 /var/www/lovebeat.sh
$ /var/www/lovebeat.sh
Hello World
LC_PAPER=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
[...] more env [...]
I see that the docker image hasn't been updated to the version that supports this. It's still on 0.8, while we have released 1.0 now.
I'll do that this evening.
Sorry about that. The binaries found in Github's releases are up to date, though.
Ok, noted, thanks.
Can you take a look at http://lovebeat.readthedocs.io/, I think this doc is outdated too.
I've updated the docker images now.
Could you please tell me what's outdated in the docs and I'll update it
The alerter configuration example does not work: http://lovebeat.readthedocs.io/en/latest/alerters.html
For script alerter it states:
[[alarms]]
name = "example"
pattern = "test.*"
alerts = ["test-alert"]
[[alarms.alerts]]
script = "/path/to/script.sh"
Which triggers an error.
The documentation in master is up to date but readthedocs.io isn't.
https://github.com/boivie/lovebeat/blob/master/docs/alerters.rst