https://github.com/little-angry-clouds/alertmanager-actions
Launch custom actions based on Alertmanager alerts
https://github.com/little-angry-clouds/alertmanager-actions
alertmanager-webhook prometheus
Last synced: 5 months ago
JSON representation
Launch custom actions based on Alertmanager alerts
- Host: GitHub
- URL: https://github.com/little-angry-clouds/alertmanager-actions
- Owner: little-angry-clouds
- License: other
- Created: 2020-03-30T06:45:50.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-23T11:52:50.000Z (almost 5 years ago)
- Last Synced: 2023-03-09T07:41:30.848Z (about 3 years ago)
- Topics: alertmanager-webhook, prometheus
- Language: Python
- Size: 85.9 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Alertmanager Actions

[](https://coveralls.io/github/little-angry-clouds/alertmanager-actions?branch=master)
[](https://lgtm.com/projects/g/little-angry-clouds/alertmanager-actions/alerts/)
[](https://lgtm.com/projects/g/little-angry-clouds/alertmanager-actions/context:python)
An Alert Manager
[receiver](https://prometheus.io/docs/alerting/configuration/#receiver) that
executes arbitrary commands when receiving alerts.
It's dead simple. You associate alert labels to an action, and it will execute
the action.
## Configuration
This program uses [pyms](https://github.com/python-microservices/pyms), the cool
library to create REST python microservices. The configuration section under
`pyms` is for that. The one under `alertmanager_actions` is the section for the
program per se:
``` yaml
pyms:
services:
metrics: true
config:
debug: false
app_name: alertmanager-actions
testing: false
alertmanager_actions:
- labels:
alertname: IpsecStatus
action: restart
command: hostname
```
You may use this to execute commands over ssh, like this:
``` yaml
pyms:
services:
metrics: true
config:
debug: false
app_name: alertmanager-actions
testing: false
alertmanager_actions:
- labels:
alertname: ExampleAlertName
action: restart
command: ssh -i /home/user/.ssh/id_rsa user@mycoolbox.com hostname
```
It's possible to read a more complete step by step documentation
[here](./docs/configuration.md).
Also, there's a docker image you may use in [Docker
Hub](https://hub.docker.com/repository/docker/littleangryclouds/alertmanager-actions).
## Metrics
It exposes some prometheus metrics. The ones that come with
[Pyms](https://py-ms.readthedocs.io/en/latest/services/#metrics)
and then ones about the Alertmanager Actions itself. The created metric would be
something like this:
``` text
# HELP alertmanager_actions_total Number of alertmanager actions executions
# TYPE alertmanager_actions_total counter
alertmanager_actions_total{action="TestActions",alertname="TestActions",state="0"} 1.0
alertmanager_actions_total{action="TestActions",alertname="TestActions",state="1"} 1.0
# HELP alertmanager_actions_created Number of alertmanager actions executions
# TYPE alertmanager_actions_created gauge
alertmanager_actions_created{action="TestActions",alertname="TestActions",state="0"} 1.5936252529745235e+09
alertmanager_actions_created{action="TestActions",alertname="TestActions",state="1"} 1.5936252952259927e+09
```
The metric's name is `alertmanager_actions_executions` and will have the next
metrics:
- action: The action name.
- state: The state of the executed command. 0 means that it worked correctly, 1
that it didn't.
- arbitrary labels: There will also be added all the labels that are used to
identify the action. Following the above example, the next labels will be
added:
- alertname: ExampleAlertName
- action: restart
## Development
### Tests
``` bash
pipenv install
pipenv run pip freeze > requirements.txt
tox
```