Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaywink/matrix-alertmanager
A bot to receive Alertmanager webhook events and forward them to chosen rooms.
https://github.com/jaywink/matrix-alertmanager
alertmanager bot matrix monitoring prometheus webhook-receiver
Last synced: 13 days ago
JSON representation
A bot to receive Alertmanager webhook events and forward them to chosen rooms.
- Host: GitHub
- URL: https://github.com/jaywink/matrix-alertmanager
- Owner: jaywink
- License: mit
- Created: 2018-12-23T21:47:30.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-14T23:08:50.000Z (about 2 months ago)
- Last Synced: 2024-10-23T12:19:10.174Z (21 days ago)
- Topics: alertmanager, bot, matrix, monitoring, prometheus, webhook-receiver
- Language: JavaScript
- Homepage:
- Size: 329 KB
- Stars: 75
- Watchers: 4
- Forks: 21
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![](https://img.shields.io/docker/pulls/jaywink/matrix-alertmanager.svg)](https://cloud.docker.com/u/jaywink/repository/docker/jaywink/matrix-alertmanager) [![](https://img.shields.io/matrix/matrix-alertmanager:federator.dev.svg?server_fqdn=federator.dev)](https://matrix.to/#/#matrix-alertmanager:federator.dev)
# Matrix-Alertmanager
![](./screenshot.png)
A bot to receive Prometheus Alertmanager webhook events and forward them to chosen rooms.
Main features:
* Uses pre-created Matrix user to send alerts using token auth.
* Configurable room per alert receiver.
* Automatic joining of configured rooms. Private rooms require an invite.
* Secret key authentication with Alertmanager.
* HTML formatted messages.
* Optionally mentions `@room` on firing alerts## How to use
### Configuration
Whether running manually or via the Docker image, the configuration is set
via environment variables. When running manually, copy `.env.default`
into `.env`, set the values and they will be loaded automatically.
When using the Docker image, set the environment variables when running
the container.### Docker
The [Docker image](https://cloud.docker.com/repository/docker/jaywink/matrix-alertmanager) `jaywink/matrix-alertmanager:latest` is the easiest way to get the service running. Ensure you set the required environment variables listed in `.env.default` in this repository.
### Alertmanager
You will need to configure a webhook receiver in Alertmanager. It should looks something like this:
```yaml
receivers:
- name: 'myreceiver'
webhook_configs:
- url: 'https://my-matrix-alertmanager.tld/alerts?secret=veryverysecretkeyhere'
```The secret key obviously should match the one in the alertmanager configuration.
Alternatively, put the secret in a separate file and use basic auth with username `alertmanager`:
```yaml
receivers:
- name: 'myreceiver'
webhook_configs:
- url: 'https://my-matrix-alertmanager.tld/alerts'
http_config:
basic_auth:
username: alertmanager
password_file: /path/to/password.secret
```### Prometheus rules
Add some styling to your prometheus rules
```yaml
rules:
- alert: High Memory Usage of Container
annotations:
description: Container named {{\$labels.container_name}} in {{\$labels.pod_name}} in {{\$labels.namespace}} is using more than 75% of Memory Limit
expr: |
((( sum(container_memory_usage_bytes{image!=\"\",container_name!=\"POD\", namespace!=\"kube-system\"}) by (namespace,container_name,pod_name, instance) / sum(container_spec_memory_limit_bytes{image!=\"\",container_name!=\"POD\",namespace!=\"kube-system\"}) by (namespace,container_name,pod_name, instance) ) * 100 ) < +Inf ) > 75
for: 5m
labels:
team: dev
```NOTE! Currently, the bot cannot talk HTTPS, so you need to have a reverse proxy in place to terminate SSL, or use unsecure unencrypted connections.
## TODO
* Registering an account instead of having to use an existing account
## Tech
Node 20, Express, Matrix JS SDK
## Help
Come chat in the https://matrix.to/#/#matrix-alertmanager:federator.dev room!
## Author
Jason Robinson / https://jasonrobinson.me / @jaywink:federator.dev
## License
MIT