Skip to main content

The application provides a Webhook integration for Prometheus AlertManager to push alerts to Google Chat rooms.

Project description

PyPI PyPI - License PyPI - Downloads docker-image-version docker-image-size docker-pulls

alertmanager-gchat-integration

Description

The application provides a Webhook integration for Prometheus AlertManager to push alerts to Google Chat rooms.

The application expects a config.toml file like this:

[app.notification]
# Helpful to indicate the origin of the message. Default to HOSTNAME.
# origin = "custom-origin"

# Optional Jinja2 custom template to print message to GChat.
# custom_template_path = "<file>.json.j2"

# Optional true to send the message as a Gchat card
# use_cards = true

[app.room.<room-name>]
notification_url = "https://chat.googleapis.com/v1/spaces/<space-id>/messages?key=<key>&token=<token>&threadKey=<threadId>"

The file may be:

  • Located in the current directory and named config.toml.
  • Placed in the directory of your choice with CONFIG_FILE_LOCATION environment variable set.

Also, the application provides a built-in template for GChat notification located here. If you wish to customize it, create a custom version and use app.notification.custom_template_path.

By default, the message will be sent as a basic message. If you wish to use cards set app.notification.use_cards to true.

When the application is started, the following endpoints are available:

  • /alerts?room=<room-name> : Endpoint used by AlertManager to send messages to GChat. The room-name should match the value indicated in the config.toml file. HTTP expected methods are: POST.
  • /healthz : return 200 OK if the service is running. HTTP expected methods are: GET.
  • /metrics : return Prometheus metrics regarding HTTP requests. HTTP expected methods are: GET.

Using the python module

$ pip install alertmanager-gchat-integration
$ CONFIG_FILE_LOCATION=config.toml python -m alertmanager_gchat_integration

Using the container

To execute the container, you should have a ~/.kube/config with the context pointing to the cluster. The user defined in the context should have the appropriate rights in th cluster to manage configmaps.

Starts the service

  • Run container as root:
$ docker run -ti \
    --user 65534:65534                      \
    -p 80:8080                              \
    -v $(pwd)/config.toml:/app/config.toml  \
    julb/alertmanager-gchat-integration:latest

The following environment variables are also available:

Environment var Description Default Value
PORT The listening port for the application. 8080
CONFIG_FILE_LOCATION The config.toml file path. /app/config.toml

Helm chart

A Helm chart is available to install this runtime.

Contributing

This project is totally open source and contributors are welcome.

When you submit a PR, please ensure that the python code is well formatted and linted.

$ make install.dependencies
$ make format
$ make lint

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alertmanager-gchat-integration-1.0.5.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file alertmanager-gchat-integration-1.0.5.tar.gz.

File metadata

  • Download URL: alertmanager-gchat-integration-1.0.5.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for alertmanager-gchat-integration-1.0.5.tar.gz
Algorithm Hash digest
SHA256 1f9737b5f97a689b9246b0b0449f6c92499fcf54427b9829d479a7a1d94b3aea
MD5 116892f06cf8d0fae01c28aeedf4043d
BLAKE2b-256 be4f6d8e80ed0dd47ebb3ac54197212a78397e13d252d6005028a56d253c97fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page