Skip to main content

Prometheus XMPP Alerts hook

Project description

prometheus-xmpp-alerts

A simple web hook that forwards prometheus alerts over XMPP.

Usage

To use, configure a web hook in alertmanager. E.g.:

receivers:
- name: 'jelmer-xmpp'
  webhook_configs:
  - url: 'http://192.168.2.1:9199/alert'

Edit the configuration file (defaults to /etc/prometheus/xmpp-alerts.yml):

jid: 'alertmanager@example.com'
password: 'PASSWORD'
# Alternatively, set a 'password_command' that should write a password to
# stdout
# password_command: 'pass show xmpp-alertmanager'
to_jid: 'jelmer@example.com'
listen_address: '192.168.2.1'
listen_port: 9199

# Text message template as jinja2; defaults to html_template with tags stripped (optional)
text_template: |
 {{ status.upper() }}: *{{ labels.alertname }}* at {{ labels.host or labels.instance }}:\
 {{ annotations.message }}. {{ generatorURL }}

You can also set the following environment variables instead:

  • XMPP_ID - XMPP JID

  • XMPP_PASS - Password

  • XMPP_RECIPIENTS - comma-separated list of recipients

  • XMPP_AMTOOL_ALLOWED - comma-separated list of users (optional)

  • WEBHOOK_HOST - Address to listen on (optional)

  • WEBHOOK_PORT - Port to listen on (optional)

  • TEXT_TEMPLATE - Template for text messages (see above, optional)

  • HTML_TEMPALTE - Template for HTML messages (see above, optional)

And run the web hook::

$ python3 -m prometheus_xmpp --config=/etc/prometheus/xmpp-alerts.yaml

If you have amtool set up, then you can also allow users to see existing alerts and manage silences. Set the amtool_allowed option to JIDs that are allowed to use amtool.

Docker file

You can build your own docker images using the Dockerfile in this directory, or use ghcr.io/jelmer/prometheus-xmpp-alerts. Provide your configuration in /config.yaml or through environment variables.

Message Format

The default message format looks something like this:

FIRING: AlertName at somehost: Alert Summary. https://prometheus.example.com/expr?...

The text_template option in the configuration can be used to customize the format, using jinja2.

Testing

The web hook can be accessed on three paths:

  • /alert: used by Prometheus to deliver alerts, expects POST requests with JSON body
  • /test: delivers a test message
  • /metrics: exposes statistics about number of alerts received

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

prometheus_xmpp_alerts-0.6.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prometheus_xmpp_alerts-0.6.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file prometheus_xmpp_alerts-0.6.0.tar.gz.

File metadata

  • Download URL: prometheus_xmpp_alerts-0.6.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prometheus_xmpp_alerts-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ed0fde7d3e1b1dd64cb3e8fc485654c43e527f4c60297783d17d27d35982ae2e
MD5 8966f8a6f16a17e5eaf54d5f91e963b3
BLAKE2b-256 f41420b0d0283804c4baa9ad96694c0602feb5b4d2600325a1bf40523d023e90

See more details on using hashes here.

Provenance

The following attestation bundles were made for prometheus_xmpp_alerts-0.6.0.tar.gz:

Publisher: wheels.yaml on jelmer/prometheus-xmpp-alerts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prometheus_xmpp_alerts-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prometheus_xmpp_alerts-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74ac994758917ec29a410b425900643c281668b7e2641ef2d0368b029c43e888
MD5 2e7203511b53387ddaecc22864cf847c
BLAKE2b-256 d0f678e1d43ed4382ebaa4d0127197f4146c4a5b16de75100498b76a5c504097

See more details on using hashes here.

Provenance

The following attestation bundles were made for prometheus_xmpp_alerts-0.6.0-py3-none-any.whl:

Publisher: wheels.yaml on jelmer/prometheus-xmpp-alerts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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