Commit 09de6c53 authored by Benjamin Graillot's avatar Benjamin Graillot

Ajout d'un webhook Prometheus

parent 8c980d4c
import json
from flask import Flask, request
import source
app = Flask(__name__)
@app.route('/',methods=['POST'])
def foo():
try:
notif = request.data.decode('utf-8')
except:
notif = request.data
print(notif)
data = json.loads(notif)
push_update = app.config['push_update']
push_update(data['commonLabels']['instance'], '\x0310{alertname}\x03 \x033{instance}\x03 {job}\x03'.format(**data['commonLabels']))
for alert in data['alerts']:
push_update(alert['labels']['instance'], '\x0310{alertname}\x03 \x033{instance}\x03 {job}\x03'.format(**alert['labels']))
return "OK"
class Prometheus(source.Source):
def __init__(self):
source.Source.__init__(self, 'prometheus', 'prometheus.adm.crans.org')
def loop(self, *args, **kwargs):
app.config['push_update'] = self.push_update
app.run(host='10.231.136.1' , port=5000)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment