{# prometheus/widget.html — the Prometheus dashboard widget (#5691): one target drawn by one template (template_view.render). A verdict naming the worst thing, then each block: its problems first with why, figures in their units beside a bar or the last day's bars, and the healthy rest packed after, past REST rows as "+N more healthy". #} {% from "_macros.html" import status_dot %} {% set REST = 6 %} {% set dot = {"crit": "crit", "warn": "warn", "ok": "ok", "dim": "paused"} %} {% set tone = {"crit": "tone-crit", "warn": "tone-warn", "ok": "tone-ok", "dim": "tone-dim"} %} {% macro shown(v) -%} {%- if v.moment %}{{ v.moment|ago }}{% elif v.text %}{{ v.text }}{% else %}—{% endif -%} {%- endmacro %} {% if problem %}
{{ problem }}
{% else %} {% set down = target.reach in ("down", "stale") %}
{%- if target.reach == "down" %}{{ target.name }} isn't answering{% elif down %}{{ target.name }} isn't being scraped{% endif %} {%- if down %}{% if target.ok_at %}; these values are from {{ target.ok_at|ago }}{% endif %}. {% endif -%} {{ view.verdict }}
{% for b in view.blocks %}
{{ b.title }}
{% if b.note %}
{{ b.note }}
{% elif b.kind == "info" %}
{% for r in b.rows %}{{ r.name }}{% if not loop.last %}; {% endif %}{% endfor %}
{% elif b.kind == "table" %} {% for c in b.columns %}{% endfor %} {% for r in b.rows %} {% for c in r.cells %}{% endfor %} {% endfor %}
{{ c }}
{{ r.name }}{{ shown(c) }}
{% else %} {% set problems = b.rows | selectattr("tone", "in", ["crit", "warn"]) | list %} {% set rest = b.rows | rejectattr("tone", "in", ["crit", "warn"]) | list %} {% set listed = problems + rest[:REST] %} {% if b.columns %}{% for c in b.columns %}{% endfor %}{% endif %} {% for r in listed %} {% for c in r.cells %}{% endfor %} {% endfor %}
Now{{ c }}
{{- status_dot(dot[r.tone]) -}} {{ r.name }} {%- if r.why %}{{ r.why }}{% endif %} {%- if r.history %}{% endif -%} {{ shown(r) }} {%- if r.bar is not none %}
{% endif -%}
{{ shown(c) }}
{% if rest|length > REST %}
+{{ rest|length - REST }} more healthy
{% endif %} {% endif %} {% endfor %}
{%- if session.user_id %}{{ target.name }}{% else %}{{ target.name }}{% endif %} {%- if target.scraped_at %}, scraped {{ target.scraped_at|ago }}{% endif %}.
{% endif %}