28 lines
631 B
Python
28 lines
631 B
Python
import typing as t
|
|
from flask import Flask, request
|
|
from . import signal
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route("/")
|
|
def root() -> t.Tuple[str, int]:
|
|
return "Not supported.", 400
|
|
|
|
|
|
@app.route("/alertmanager", methods=["POST"])
|
|
def alertmanager():
|
|
data = request.get_json(cache=False)
|
|
if "version" not in data or int(data["version"]) != 4:
|
|
return "Bad API version", 400
|
|
if "alerts" not in data:
|
|
return "No alerts", 400
|
|
if "status" not in data:
|
|
return "No status", 400
|
|
if data["status"] != "firing":
|
|
# Ignore
|
|
return "OK", 200
|
|
|
|
for alert in data["alerts"]:
|
|
...
|