All Projects → MikeSafonov → prometheus-telegram-alert

MikeSafonov / prometheus-telegram-alert

Licence: MIT license
Transfer alerts from Prometheus Alertmanager to Telegram chat and channels using webhook.

Programming Languages

java
68154 projects - #9 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to prometheus-telegram-alert

Graylog-Plugin-AlertManager-Callback
A plugin for Graylog which provides the possibility to send alerts to the Prometheus AlertManager API.
Stars: ✭ 23 (+35.29%)
Mutual labels:  prometheus-alertmanager

Prometheus Alertmanager Telegram

This Spring Boot application helps to transfer alerts from Prometheus Alertmanager to Telegram chat and channels using webhooks and spring-boot-starter-prometheus-alerts

codecov Travis-CI Conventional Commits

Quality Gate Status Reliability Rating Maintainability Rating Security Rating

Bugs Code Smells Vulnerabilities

Duplicated Lines (%) Lines of Code Technical Debt

Getting started

Build from source

You can build application using following command:

./gradlew clean build

Testing

You can run unit test using following command:

./gradlew test

Configuration

According to Spring Docs you can override default application properties by put custom application.properties file in one of the following locations:

  • a /config subdirectory of the current directory
  • the current directory

The following properties can be configured in application.properties:

property description
prometheus.alertmanager.endpoint.base base url for POST request mapping for prometheus alert (default /alert)
server.port application port (default 8080)
prometheus.telegram.auth-token telegram bot auth token
prometheus.telegram.chat-id telegram chat id
prometheus.telegram.proxy.enable is use proxy (default false)
prometheus.telegram.proxy.host proxy host
prometheus.telegram.proxy.port proxy port

Running jar

You can run application using following command:

java -jar prometheus-telegram-alert.jar

You can test application by sending POST request with request body from test alerts/simple.json file.

Building and running app with Docker and docker-compose

  • For building the application and creation Docker image run

     docker-compose build
    
  • Customise configs with you preferred editor

    place configs in ./config directory

  • Run the docker image

     docker-compose up -d
    

Alertmanager configuration

route:
  receiver: 'telegram'
receivers:
- name: 'telegram'
  webhook_configs:
    - url: http://<application-host>:<application-port>/alert

Message format

You can create your own message format by implementing MessageConverter.java.

Holding secrets with HashiCorp Vault

Integration with Vault was made using spring-cloud-vault.

By default prometheus-telegram-alert integration with Vault disabled.

To enable integration with Vault pass following arguments to prometheus-telegram-alert run command:

java -jar prometheus-telegram-alert.jar --spring.cloud.vault.enabled=true --spring.cloud.vault.uri=<your vault uri> 
--spring.cloud.vault.token=<your vault token> --spring.cloud.vault.kv.application-name=<vault application name>

Contributing

Feel free to contribute. New feature proposals and bug fixes should be submitted as GitHub pull requests. Fork the repository on GitHub, prepare your change on your forked copy, and submit a pull request.

IMPORTANT!

Before contributing please read about Conventional Commits / Conventional Commits RU

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].