activity: basic webhook alerts for automation failures
This commit is contained in:
parent
eb372bec59
commit
ac4f9b4942
12 changed files with 300 additions and 3 deletions
|
@ -3,6 +3,7 @@ from datetime import datetime, timedelta, timezone
|
|||
from flask import Blueprint, render_template, request
|
||||
from sqlalchemy import desc, or_
|
||||
|
||||
from app.models.activity import Activity
|
||||
from app.models.alarms import Alarm
|
||||
from app.models.mirrors import Origin, Proxy
|
||||
from app.models.base import Group
|
||||
|
@ -16,6 +17,7 @@ from app.portal.list import bp as list_
|
|||
from app.portal.origin import bp as origin
|
||||
from app.portal.onion import bp as onion
|
||||
from app.portal.proxy import bp as proxy
|
||||
from app.portal.webhook import bp as webhook
|
||||
|
||||
portal = Blueprint("portal", __name__, template_folder="templates", static_folder="static")
|
||||
portal.register_blueprint(automation, url_prefix="/automation")
|
||||
|
@ -27,6 +29,7 @@ portal.register_blueprint(list_, url_prefix="/list")
|
|||
portal.register_blueprint(origin, url_prefix="/origin")
|
||||
portal.register_blueprint(onion, url_prefix="/onion")
|
||||
portal.register_blueprint(proxy, url_prefix="/proxy")
|
||||
portal.register_blueprint(webhook, url_prefix="/webhook")
|
||||
|
||||
|
||||
@portal.app_template_filter("mirror_expiry")
|
||||
|
@ -57,8 +60,9 @@ def portal_home():
|
|||
s: len(Alarm.query.filter(Alarm.alarm_state == s.upper(), Alarm.last_updated > (now - timedelta(days=1))).all())
|
||||
for s in ["critical", "warning", "ok", "unknown"]
|
||||
}
|
||||
activity = Activity.query.filter(Activity.added > (now - timedelta(days=2))).order_by(desc(Activity.added)).all()
|
||||
return render_template("home.html.j2", section="home", groups=groups, last24=last24, last72=last72,
|
||||
lastweek=lastweek, proxies=proxies, **alarms)
|
||||
lastweek=lastweek, proxies=proxies, **alarms, activity=activity)
|
||||
|
||||
|
||||
@portal.route("/search")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue