{"id":13471636,"url":"https://github.com/metalmatze/alertmanager-bot","last_synced_at":"2025-03-26T13:31:20.707Z","repository":{"id":38420567,"uuid":"74796103","full_name":"metalmatze/alertmanager-bot","owner":"metalmatze","description":"[deprecated] Bot for Prometheus' Alertmanager","archived":true,"fork":false,"pushed_at":"2022-04-19T20:05:47.000Z","size":1141,"stargazers_count":659,"open_issues_count":33,"forks_count":148,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-30T02:59:50.773Z","etag":null,"topics":["alertmanager","boltdb","bot","chatops","consul","monitoring","prometheus","telegram"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metalmatze.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-26T00:44:30.000Z","updated_at":"2024-10-15T14:39:09.000Z","dependencies_parsed_at":"2022-08-18T08:20:33.264Z","dependency_job_id":null,"html_url":"https://github.com/metalmatze/alertmanager-bot","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metalmatze%2Falertmanager-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metalmatze%2Falertmanager-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metalmatze%2Falertmanager-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metalmatze%2Falertmanager-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metalmatze","download_url":"https://codeload.github.com/metalmatze/alertmanager-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245662866,"owners_count":20652097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alertmanager","boltdb","bot","chatops","consul","monitoring","prometheus","telegram"],"created_at":"2024-07-31T16:00:47.687Z","updated_at":"2025-03-26T13:31:20.297Z","avatar_url":"https://github.com/metalmatze.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# ⚠️ This project is deprecated ⚠️ \n\nAlertmanager v0.24+ has Telegram support out of the box. Going forward, please simply use Alertmanager instead of this bot.  \nThis project **will be archived at the end of July 2022**.\n\nUntil then you can ask questions in [this GitHub Discussion](https://github.com/metalmatze/alertmanager-bot/discussions/210).\n\n# Bot for Prometheus' Alertmanager\n\n[![Docker Pulls](https://img.shields.io/docker/pulls/metalmatze/alertmanager-bot.svg?maxAge=604800)](https://hub.docker.com/r/metalmatze/alertmanager-bot)\n[![Go Report Card](https://goreportcard.com/badge/github.com/metalmatze/alertmanager-bot)](https://goreportcard.com/report/github.com/metalmatze/alertmanager-bot)\n\n\nThis is the [Alertmanager](https://prometheus.io/docs/alerting/alertmanager/) bot for\n[Prometheus](https://prometheus.io/) that notifies you on alerts.  \nJust configure the Alertmanager to send Webhooks to the bot and that's it.\n\nAdditionally you can always **send commands** to get up-to-date information from the alertmanager.\n\n### Why?\n\nAlertmanager already integrates a lot of different messengers as receivers for alerts.  \nI want to extend this basic functionality.\n\nPreviously the Alertmanager could only talk to you via a chat, but now you can talk back via [commands](#commands).  \nYou can ask about current ongoing [alerts](#alerts) and [silences](#silences).  \nIn the future I plan to also support silencing via the chat, so you can silences after getting an alert from within the chat.  \nA lot of other things can be added!\n\n## Messengers\n\nRight now it supports [Telegram](https://telegram.org/), but I'd like to [add more](#more-messengers) in the future.\n\n## Commands\n\n###### /start\n\n\u003e Hey, Matthias! I will now keep you up to date!  \n\u003e [/help](#help)\n\n###### /stop\n\n\u003e Alright, Matthias! I won't talk to you again.  \n\u003e [/help](#help)\n\n###### /alerts\n\n\u003e 🔥 **FIRING** 🔥  \n\u003e **NodeDown** (Node scraper.krautreporter:8080 down)  \n\u003e scraper.krautreporter:8080 has been down for more than 1 minute.  \n\u003e **Started**: 1 week 2 days 3 hours 50 minutes 42 seconds ago  \n\u003e\n\u003e 🔥 **FIRING** 🔥\n\u003e **monitored_service_down** (MONITORED SERVICE DOWN)\n\u003e The monitoring service 'digitalocean-exporter' is down.\n\u003e **Started**: 10 seconds ago\n\n###### /silences\n\n\u003e NodeDown 🔕  \n\u003e  `job=\"ranch-eye\" monitor=\"exporter-metrics\" severity=\"page\"`  \n\u003e **Started**: 1 month 1 week 5 days 8 hours 27 minutes 57 seconds ago  \n\u003e **Ends**: -11 months 2 weeks 2 days 19 hours 15 minutes 24 seconds  \n\u003e\n\u003e RancherServiceState 🔕  \n\u003e  `job=\"rancher\" monitor=\"exporter-metrics\" name=\"scraper\" rancherURL=\"http://rancher.example.com/v1\" severity=\"page\" state=\"inactive\"`  \n\u003e **Started**: 1 week 2 days 3 hours 46 minutes 21 seconds ago  \n\u003e **Ends**: -3 weeks 1 day 13 minutes 24 seconds  \n\n###### /chats\n\n\u003e Currently these chat have subscribed:\n\u003e @MetalMatze\n\n\n###### /status\n\n\u003e **AlertManager**  \n\u003e Version: 0.5.1  \n\u003e Uptime: 3 weeks 1 day 6 hours 15 minutes 2 seconds  \n\u003e **AlertManager Bot**  \n\u003e Version: 0.4.3  \n\u003e Uptime: 3 weeks 1 hour 17 minutes 19 seconds  \n\n###### /help\n\n\u003e I'm a Prometheus AlertManager Bot for Telegram. I will notify you about alerts.  \n\u003e You can also ask me about my [/status](#status), [/alerts](#alerts) \u0026 [/silences](#silences)  \n\u003e   \n\u003e Available commands:  \n\u003e [/start](#start) - Subscribe for alerts.  \n\u003e [/stop](#stop) - Unsubscribe for alerts.  \n\u003e [/status](#status) - Print the current status.  \n\u003e [/alerts](#alerts) - List all alerts.  \n\u003e [/silences](#silences) - List all silences.  \n\u003e [/chats](#chats) - List all users and group chats that subscribed.\n\n## Installation\n\n### Docker\n\n`docker pull metalmatze/alertmanager-bot:0.4.3`\n\nStart as a command:\n\n#### Bolt Storage\n\n```bash\ndocker run -d \\\n\t-e 'ALERTMANAGER_URL=http://alertmanager:9093' \\\n\t-e 'BOLT_PATH=/data/bot.db' \\\n\t-e 'STORE=bolt' \\\n\t-e 'TELEGRAM_ADMIN=1234567' \\\n\t-e 'TELEGRAM_TOKEN=XXX' \\\n\t-v '/srv/monitoring/alertmanager-bot:/data' \\\n\t--name alertmanager-bot \\\n\tmetalmatze/alertmanager-bot:0.4.3\n```\n\n#### Consul Storage\n\n```bash\ndocker run -d \\\n\t-e 'ALERTMANAGER_URL=http://alertmanager:9093' \\\n\t-e 'CONSUL_URL=localhost:8500' \\\n\t-e 'STORE=consul' \\\n\t-e 'TELEGRAM_ADMIN=1234567' \\\n\t-e 'TELEGRAM_TOKEN=XXX' \\\n\t--name alertmanager-bot \\\n\tmetalmatze/alertmanager-bot:0.4.3\n```\n\n#### ETCD Storage\n\n```bash\ndocker run -d \\\n\t-e 'ALERTMANAGER_URL=http://alertmanager:9093' \\\n\t-e 'ETCD_URL=localhost:2379' \\\n\t-e 'STORE=etcd' \\\n\t-e 'ETCD_TLS_INSECURE=true' \\\n\t-e 'TELEGRAM_ADMIN=1234567' \\\n\t-e 'TELEGRAM_TOKEN=XXX' \\\n\t--name alertmanager-bot \\\n\tmetalmatze/alertmanager-bot:0.4.2\n```\n\n### docker-compose:\n\n[embedmd]:# (deployments/examples/docker-compose.yaml)\n```yaml\nnetworks:\n  alertmanager-bot: {}\nservices:\n  alertmanager-bot:\n    command:\n    - --alertmanager.url=http://localhost:9093\n    - --log.level=info\n    - --store=bolt\n    - --bolt.path=/data/bot.db\n    environment:\n      TELEGRAM_ADMIN: \"1234\"\n      TELEGRAM_TOKEN: XXXXXXX\n    image: metalmatze/alertmanager-bot:0.4.3\n    networks:\n    - alertmanager-bot\n    ports:\n    - 8080:8080\n    restart: always\n    volumes:\n    - ./data:/data\nversion: \"3\"\n```\n\n### Kubernetes:\n\n[embedmd]:# (deployments/examples/kubernetes.yaml)\n```yaml\napiVersion: v1\nitems:\n- apiVersion: v1\n  data:\n    admin: MTIzNA==\n    token: WFhYWFhYWA==\n  kind: Secret\n  metadata:\n    labels:\n      app.kubernetes.io/name: alertmanager-bot\n    name: alertmanager-bot\n    namespace: monitoring\n  type: Opaque\n- apiVersion: v1\n  kind: Service\n  metadata:\n    labels:\n      app.kubernetes.io/name: alertmanager-bot\n    name: alertmanager-bot\n    namespace: monitoring\n  spec:\n    ports:\n    - name: http\n      port: 8080\n      targetPort: 8080\n    selector:\n      app.kubernetes.io/name: alertmanager-bot\n- apiVersion: apps/v1\n  kind: StatefulSet\n  metadata:\n    labels:\n      app.kubernetes.io/name: alertmanager-bot\n    name: alertmanager-bot\n    namespace: monitoring\n  spec:\n    podManagementPolicy: OrderedReady\n    replicas: 1\n    selector:\n      matchLabels:\n        app.kubernetes.io/name: alertmanager-bot\n    serviceName: alertmanager-bot\n    template:\n      metadata:\n        labels:\n          app.kubernetes.io/name: alertmanager-bot\n        name: alertmanager-bot\n        namespace: monitoring\n      spec:\n        containers:\n        - args:\n          - --alertmanager.url=http://localhost:9093\n          - --log.level=info\n          - --store=bolt\n          - --bolt.path=/data/bot.db\n          env:\n          - name: TELEGRAM_ADMIN\n            valueFrom:\n              secretKeyRef:\n                key: admin\n                name: alertmanager-bot\n          - name: TELEGRAM_TOKEN\n            valueFrom:\n              secretKeyRef:\n                key: token\n                name: alertmanager-bot\n          image: metalmatze/alertmanager-bot:0.4.3\n          imagePullPolicy: IfNotPresent\n          name: alertmanager-bot\n          ports:\n          - containerPort: 8080\n            name: http\n          resources:\n            limits:\n              cpu: 100m\n              memory: 128Mi\n            requests:\n              cpu: 25m\n              memory: 64Mi\n          volumeMounts:\n          - mountPath: /data\n            name: data\n        restartPolicy: Always\n        volumes:\n        - name: data\n          persistentVolumeClaim:\n            claimName: alertmanager-bot\n    volumeClaimTemplates:\n    - apiVersion: v1\n      kind: PersistentVolumeClaim\n      metadata:\n        labels:\n          app.kubernetes.io/name: alertmanager-bot\n        name: alertmanager-bot\n        namespace: monitoring\n      spec:\n        accessModes:\n        - ReadWriteOnce\n        resources:\n          requests:\n            storage: 1Gi\n        storageClassName: standard\nkind: List\n```\n\n### Ansible\n\nIf you prefer using configuration management systems (like Ansible) you might be interested in the following role:  [mbaran0v.alertmanager-bot](https://github.com/mbaran0v/ansible-role-alertmanager-bot)\n\n### Build from source\n\n`GO111MODULE=on go get github.com/metalmatze/alertmanager-bot/cmd/alertmanager-bot`\n\n### Configuration\n\n| ENV Variable                  | CLI flag                    | Required | Default                 | Description                                                                                                                                                                                                                          |   |   |   |\n|-------------------------------|-----------------------------|----------|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|---|---|\n| ALERTMANAGER_URL              | alertmanager.url            |          | http://localhost:9093   | Address of the alertmanager                                                                                                                                                                                                          |   |   |   |\n| BOLT_PATH                     | bolt.path                   |          | /tmp/bot.db             | Path on disk to the file where the boltdb is stored                                                                                                                                                                                  |   |   |   |\n| CONSUL_URL                    | consul.url                  |          | localhost:8500          | The URL to use to connect with Consul                                                                                                                                                                                                |   |   |   |\n| LISTEN_ADDR                   | listen.addr                 |          | 0.0.0.0:8080            | Address that the bot listens for webhooks                                                                                                                                                                                            |   |   |   |\n| STORE                         | store                       | ✓        |                         | The type of the store to use, choose from bolt (local), consul or etcd (distributed)                                                                                                                                                 |   |   |   |\n| STORE_KEY_PREFIX              | storeKeyPrefix              |          | telegram/chats          | Key prefix for the store                                                                                                                                                                                                             |   |   |   |\n| ETCD_URL                      | etcd.url                    |          | localhost:2379          | The URL that's used to connect to the ETCD store                                                                                                                                                                                     |   |   |   |\n| ETCD_TLS_INSECURE             | etcd.tls.insecure           |          | false                   | Use TLS connection to ETCD store or not                                                                                                                                                                                              |   |   |   |\n| ETCD_TLS_INSECURE_SKIP_VERIFY | etcd.tls.insecureSkipVerify |          |                         | Skip server certificates verification                                                                                                                                                                                                |   |   |   |\n| ETCD_TLS_CERT                 | etcd.tls.cert               |          |                         | Path to the TLS cert file                                                                                                                                                                                                            |   |   |   |\n| ETCD_TLS_KEY                  | etcd.tls.key                |          |                         | Path to the TLS key file                                                                                                                                                                                                             |   |   |   |\n| ETCD_TLS_CACERT               | etcd.tls.ca                 |          |                         | Path to the TLS trusted CA cert file                                                                                                                                                                                                 |   |   |   |\n| LOG_JSON                      | log.json                    |          |                         | Tell the application to log json and not key value pairs                                                                                                                                                                             |   |   |   |\n| LOG_LEVEL                     | log.level                   |          | info                    | The log level to use for filtering logs. Possible values: debug, info, warn, error                                                                                                                                                   |   |   |   |\n| TELEGRAM_ADMIN                | telegram.admin              | ✓        |                         | The Telegram user id for the admin (not the bot itself, you, the user). The bot will only reply to messages sent from an admin. All other messages are dropped and logged on the bot's console.  Your user id you can get from [@userinfobot](https://t.me/userinfobot). |   |   |   |\n| TELEGRAM_TOKEN                | telegram.token              | ✓        |                         | Token you get from [@botfather](https://telegram.me/botfather)                                                                                                                                                                       |   |   |   |\n| TEMPLATE_PATHS                | template.paths              |          | /templates/default.tmpl | Path to custom message templates                                                                                                                                                                                                     |   |   |   |\n\n#### Authentication\n\nAdditional users may be allowed to command the bot by giving multiple instances\nof the `--telegram.admin` command line option or by specifying a\nnewline-separated list of telegram user IDs in the `TELEGRAM_ADMIN` environment\nvariable.\n```\n- TELEGRAM_ADMIN=\"**********\\n************\"\n--telegram.admin=1 --telegram.admin=2\n```\n#### Alertmanager Configuration\n\nNow you need to connect the Alertmanager to send alerts to the bot.  \nA webhook is used for that, so make sure your `LISTEN_ADDR` is reachable for the Alertmanager.\n\nFor example add this to your `alertmanager.yml` configuration:\n```yaml\nreceivers:\n- name: 'alertmanager-bot'\n  webhook_configs:\n  - send_resolved: true\n    url: 'http://alertmanager-bot:8080'\n```\n\n## Development\n\nBuild the binary using `make`:\n\n```\nmake\n```\n\nIn case you have `$GOPATH/bin` in your `$PATH` you can now simply start the bot by running:\n\n```bash\nalertmanager-bot\n```\n\n## Missing\n\n##### Commands\n\n* `/silence` - show a specific silence  \n* `/silence_del` - delete a silence by command  \n* `/silence_add` - add a silence for a alert by command\n\n##### More Messengers\n\nAt the moment I only implemented Telegram, because it's so freakin' easy to do.\n\nMessengers considered to add in the future:\n\n* [Slack](https://slack.com/)\n* [Mattermost](https://about.mattermost.com/)\n* [Matrix](https://matrix.org/)\n\nIf one is missing for you just open an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetalmatze%2Falertmanager-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetalmatze%2Falertmanager-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetalmatze%2Falertmanager-bot/lists"}