MOVED TO GITLAB https://gitlab.wikimedia.org/repos/sre/phalerts

Clone this repo:
  1. 718b90e Merge tag 'upstream/e2a0b3a' by Andrea Denisse Gómez-Martínez · 12 months ago master
  2. e2a0b3a Fix metrics issue #8 by Stefan Safar · 2 years ago upstream/e2a0b3a
  3. 60942d8 Override task title template from query string by Filippo Giunchedi · 2 years, 10 months ago
  4. 3363108 Merge tag 'upstream/0+git20220228.44a65d10' by Filippo Giunchedi · 2 years, 10 months ago
  5. 44a65d1 Override title template from query string by Filippo Giunchedi · 2 years, 10 months ago upstream/0+git20220228.44a65d10

Build Status Coverage Status

Phabricator webhook for Prometheus Alertmanager

phalerts is a simple service that implements Alertmanager webhook receiver API and creates/updates Phabricator tasks based on alert notifications from Alertmanager.

The service:

  • determines task title and description based on notification fields;
  • if there is an existing open task with a given title, updates its description if necessary;
  • if there is no open task, created a new one.

You can optionally provide a project name/ID (or several) and phalerts will only look for tasks in that project, and will assign that project to all new tasks it creates.

Usage

You will need to create a bot account which will be used to manage alert-based tasks and generate an API token via [Bot User] > Manage > Edit Settings > Conduit API Tokens.

phalerts expects the token to be present in PHABRICATOR_TOKEN environment variable, so you'll typically use a command like this to start it:

PHABRICATOR_TOKEN=api-xxxxxx phalerts.py https://phab.company.tld bot-username

Then configure a new receiver in Alertmanager configuration file. For example, to create/update tasks in the prometheus-alerts Phabricator project, define:

receivers:
- name: phalerts
  webhook_configs:
  - url: http://localhost:8292/alerts?project=prometheus-alerts
    send_resolved: false

At each call the Phabricator ID (PHID) for prometheus-alerts will be looked up. Specifying IDs is also supported via the phid query string parameter.

Finally, actually route some alerts to the receiver you've created.

Title template

Tasks created by phalerts will be titled by a jinja template, by default the alert group's name (--tpl_format CLI option). You can override the title template with the title query string parameter.

Known issues

Search queries issued to Phabricator only process first 100 results. This is unlikely to be a problem (especially for small installations), however you might need to implement paging support in phalerts if you have many projects or open tasks with similar names. You should see phalerts_request_errors_total counter incremented and "Unexpected 'after' cursor" error messages if this becomes a problem.

License

Licensed under MIT license.

  NODES
os 2
web 3