Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

webserver: add webhook for prometheus alerts #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dkess
Copy link
Member

@dkess dkess commented Nov 5, 2019

This is pretty much a copy of the code from #76.

We'll start off with the #rebuild-spam channel for now, but if this works out well we can extend this to use custom channels (configured by Prometheus) and then utilize the #opstaff-alerts channel.

It looks like this:

<create> OK TestAlert: This is what a Prometheus alert looks like

In IRC, OK or FIRING show up as green and red respectively, and the part before the colon is bold.

@dkess dkess requested a review from fydai November 5, 2019 03:55
@dkess
Copy link
Member Author

dkess commented Nov 5, 2019

Oh actually can we use f-strings now? 🤔

alert = '{status} \x02{alertname}\x0F: {summary}'.format(
status=status,
alertname=alert['labels']['alertname'],
summary=alert['annotations']['summary'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be extra safe and do a check here that these exist in the dictionary. The annotations section is entirely optional (if you don't believe me, you can verify this with promtool). Right now all the alerts we have a summary, but we don't have documentation for OCF alert standards, so some could eventually slip in without it.

@@ -52,6 +53,25 @@ def route_macros():
)


@app.route('/hook/prometheus', methods=['POST'])
def route_prometheus():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is stopping me from sending a fake alert

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing, but if it becomes a problem we can add an HTTP password check.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants