Send grafana alerts to matrix rooms
Find a file
Alyx a75121b837
All checks were successful
Build and publish a docker container based on the latest commit / publish-container (docker-amd64) (push) Successful in 2m41s
Build and publish a docker container based on the latest commit / publish-container (docker-arm64) (push) Successful in 2m48s
Build and publish a docker container based on the latest commit / combined-manifest (push) Successful in 9s
Added arm64 builds
2025-03-14 08:30:44 +00:00
.forgejo/workflows Added arm64 builds 2025-03-14 08:30:44 +00:00
.idea Init 2025-03-10 16:41:25 +00:00
_README Init 2025-03-10 16:41:25 +00:00
actions New namespace 2025-03-12 21:56:03 +00:00
config Init 2025-03-10 16:41:25 +00:00
logger Init 2025-03-10 16:41:25 +00:00
mautrixClient New namespace 2025-03-12 21:56:03 +00:00
router New namespace 2025-03-12 21:56:03 +00:00
.gitignore Init 2025-03-10 16:41:25 +00:00
docker-compose.yml Init 2025-03-10 16:41:25 +00:00
Dockerfile Init 2025-03-10 16:41:25 +00:00
go.mod New namespace 2025-03-12 21:56:03 +00:00
LICENSE Initial commit 2025-03-10 15:00:59 +00:00
main.go New namespace 2025-03-12 21:56:03 +00:00
README.md New docker registry url 2025-03-12 21:53:57 +00:00

Grafana Matrix Alerts

This project offers an easy method to forward Grafana alerts to a (encrypted) Matrix room.

Simply configure a Grafana webhook alert channel to direct alerts to this bot. The bot will then send the incoming webhook as a Matrix message to the specified chat room.


screenshot of matrix alert message

1. Features

  • 🔒 E2EE Support
    • Support for encrypted matrix rooms
  • 📎 Simple
    • No config files, all required parameters provided on startup
  • 🪁 Flexible
    • Support multiple grafana alert channels to multiple matrix rooms

Usage

Docker Container

We provide prebuilt docker images, and you can use the example docker-compose.yaml:

services:
  grafana-matrix-alerts:
    image: lavaforge.org/alyx/grafana-matrix-alerts:latest
    container_name: grafana-matrix-alerts
    restart: unless-stopped
    environment:
      GMA_HOMESERVER: "matrix.org"
      GMA_USERNAME: "grafana-bot"
      GMA_PASSWORD: "Trains?!"
      GMA_RECOVERYKEY: "TRANSRIGHTSAREHUMANRIGHTS!"
    volumes:
      - ./data:/data

Grafana Config

Add a new Contact Point in Grafana with the POST webhook type. Use the following URL:

http://<ip address>:8080/api/v1/unified/<roomId>

Replace <roomId> with the ID of the room where you would like to receive the notifications.
The bot tells you the room ID once you invite it to a room. Alternatively, you can look up the room ID in the room details of your Matrix client.

Attention

The bot is designed to run locally on your Grafana server; therefore, it doesn't have any authentication mechanism. This means that, theoretically, anyone with the address can send notifications to the webhook endpoint.

Please make sure that it can only be accessed internally by your Grafana server.

Configuration

The bot is configured through environment variables. The following configuration options are available:

Environment Variable Default value Required Description
GMA_PORT 8080 No Port used by the webserver, which is listening for the webhook calls
GMA_HOMESERVER N/A Yes Your matrix homeserver
GMA_USERNAME N/A Yes The username used to login to your matrix server.
GMA_PASSWORD N/A Yes The matrix user password
GMA_DATABASE /data/gma.db No Path to the database
GMA_RECOVERYKEY N/A Yes The recovery key of your matrix account. This is used so the bot can verify itself. Can be removed after successful verification.
GMA_DEBUGLOG false No Enables the debug level log output

Thanks

Thanks a lot to Hector from grafana-matrix-forwarder, which this bot is heavily inspired by.
This bot is made possible by the maunium.net/go/mautrix library.