Giter VIP home page Giter VIP logo

phalerts's Introduction

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.

phalerts's People

Contributors

filippog avatar knyar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

phalerts's Issues

Override task title template from url?

Hello,
thank you for phalerts! Super useful and works well. We're running into a situation where the default tpl_title of {{ groupLabels.alertname }} is fine for most alerts, but not all. Specifically for network devices alerts we want to group tasks by device (e.g. in instance label) whereas normally task grouped by alertname make sense and it is what we want.

I was thinking a possible solution would be giving users the ability to override the template via query string arguments, e.g. /alerts?project=foo&tpl_title={{ ... }} (not escaped but you get the idea). What do you think ? I'm happy to contribute a PR and wanted to share/discuss first. Thank you !

Support for passing PHIDs ?

Hi,
thank you again for phalerts! I'd like to be able to pass PHIDs as well as project names; the main reason being that projects can get renamed but PHIDs stay the same. Is that something you are interested in? e.g. supporting phid on the query string. I'm happy to help with a PR, but wanted to gauge interest first.

Metrics endpoint returns 500

I was testing the service but /metrics endpoint doesn't work in my case for some reason:

# curl -vvv http://127.0.0.1:8293/metrics
* Expire in 0 ms for 6 (transfer 0x559a8c0b80f0)
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x559a8c0b80f0)
* Connected to 127.0.0.1 (127.0.0.1) port 8293 (#0)
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:8293
> User-Agent: curl/7.64.0
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 500 INTERNAL SERVER ERROR
< Content-Type: text/html; charset=utf-8
< Content-Length: 290
< Server: Werkzeug/1.0.1 Python/3.8.8
< Date: Thu, 08 Sep 2022 13:22:50 GMT
< 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>

Could you verify it once you have time pls ?

Thx

Copyright statement?

Hi,
thank you for phalerts! I'm trying it out and was wondering who's the copyright holder? I couldn't find any statement in the source.

thank you!
Filippo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.