16 lines
576 B
Python
16 lines
576 B
Python
#!/usr/bin/env python3
|
|
|
|
from . import app
|
|
from .utils import process_instance
|
|
|
|
from flask import render_template
|
|
import json
|
|
import requests
|
|
|
|
@app.route("/")
|
|
def status():
|
|
r = requests.get(app.config["PROMETHEUS_API_BASE"] + "/api/v1/query?query=%28sum_over_time%28up%7Bjob%3D%22node-exporter%22%7D%5B6h%5D%29+%2F+count_over_time%28up%7Bjob%3D%22node-exporter%22%7D%5B6h%5D%29%29%5B14d%3A6h%5D")
|
|
j = json.loads(r.text)
|
|
metrics = sorted(map(process_instance, j["data"]["result"]), key=lambda m: m["name"])
|
|
return render_template("status.html", metrics=metrics)
|