2021-09-07 21:39:22 +02:00
|
|
|
{% package main %}
|
|
|
|
|
|
|
|
{% import (
|
|
|
|
"time"
|
|
|
|
"sort"
|
2022-07-06 10:46:01 +02:00
|
|
|
"net/http"
|
2021-09-07 21:39:22 +02:00
|
|
|
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/tpl"
|
2022-07-08 10:26:13 +02:00
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/utils"
|
2022-02-02 13:11:41 +01:00
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/notifier"
|
2021-09-07 21:39:22 +02:00
|
|
|
) %}
|
|
|
|
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{% func Welcome(r *http.Request) %}
|
|
|
|
{%= tpl.Header(r, navItems, "vmalert") %}
|
2021-09-07 21:39:22 +02:00
|
|
|
<p>
|
|
|
|
API:<br>
|
2021-09-21 13:41:01 +02:00
|
|
|
{% for _, p := range apiLinks %}
|
2022-12-09 20:43:54 +01:00
|
|
|
{%code p, doc := p[0], p[1] %}
|
|
|
|
<a href="{%s p %}">{%s p %}</a> - {%s doc %}<br/>
|
2021-09-07 21:39:22 +02:00
|
|
|
{% endfor %}
|
2022-12-09 20:43:54 +01:00
|
|
|
{% if r.Header.Get("X-Forwarded-For") == "" %}
|
|
|
|
System:<br>
|
|
|
|
{% for _, p := range systemLinks %}
|
|
|
|
{%code p, doc := p[0], p[1] %}
|
|
|
|
<a href="{%s p %}">{%s p %}</a> - {%s doc %}<br/>
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2021-09-07 21:39:22 +02:00
|
|
|
</p>
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Footer(r) %}
|
2021-09-07 21:39:22 +02:00
|
|
|
{% endfunc %}
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{% func ListGroups(r *http.Request, groups []APIGroup) %}
|
2022-09-14 14:04:24 +02:00
|
|
|
{%code prefix := utils.Prefix(r.URL.Path) %}
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Header(r, navItems, "Groups") %}
|
2021-09-07 21:39:22 +02:00
|
|
|
{% if len(groups) > 0 %}
|
|
|
|
{%code
|
|
|
|
rOk := make(map[string]int)
|
|
|
|
rNotOk := make(map[string]int)
|
|
|
|
for _, g := range groups {
|
2022-03-15 12:54:53 +01:00
|
|
|
for _, r := range g.Rules {
|
2021-09-07 21:39:22 +02:00
|
|
|
if r.LastError != "" {
|
2023-02-08 14:34:03 +01:00
|
|
|
rNotOk[g.ID]++
|
2021-09-07 21:39:22 +02:00
|
|
|
} else {
|
2023-02-08 14:34:03 +01:00
|
|
|
rOk[g.ID]++
|
2021-09-07 21:39:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
<a class="btn btn-primary" role="button" onclick="collapseAll()">Collapse All</a>
|
|
|
|
<a class="btn btn-primary" role="button" onclick="expandAll()">Expand All</a>
|
|
|
|
{% for _, g := range groups %}
|
2023-02-08 14:34:03 +01:00
|
|
|
<div class="group-heading{% if rNotOk[g.ID] > 0 %} alert-danger{% endif %}" data-bs-target="rules-{%s g.ID %}">
|
2021-09-07 21:39:22 +02:00
|
|
|
<span class="anchor" id="group-{%s g.ID %}"></span>
|
2022-03-15 12:54:53 +01:00
|
|
|
<a href="#group-{%s g.ID %}">{%s g.Name %}{% if g.Type != "prometheus" %} ({%s g.Type %}){% endif %} (every {%f.0 g.Interval %}s)</a>
|
2023-02-08 14:34:03 +01:00
|
|
|
{% if rNotOk[g.ID] > 0 %}<span class="badge bg-danger" title="Number of rules with status Error">{%d rNotOk[g.ID] %}</span> {% endif %}
|
|
|
|
<span class="badge bg-success" title="Number of rules withs status Ok">{%d rOk[g.ID] %}</span>
|
2021-09-07 21:39:22 +02:00
|
|
|
<p class="fs-6 fw-lighter">{%s g.File %}</p>
|
2021-12-02 13:45:08 +01:00
|
|
|
{% if len(g.Params) > 0 %}
|
|
|
|
<div class="fs-6 fw-lighter">Extra params
|
|
|
|
{% for _, param := range g.Params %}
|
|
|
|
<span class="float-left badge bg-primary">{%s param %}</span>
|
2021-09-13 13:11:38 +02:00
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2022-07-21 15:59:55 +02:00
|
|
|
{% if len(g.Headers) > 0 %}
|
|
|
|
<div class="fs-6 fw-lighter">Extra headers
|
|
|
|
{% for _, header := range g.Headers %}
|
|
|
|
<span class="float-left badge bg-primary">{%s header %}</span>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-09-07 21:39:22 +02:00
|
|
|
</div>
|
|
|
|
<div class="collapse" id="rules-{%s g.ID %}">
|
|
|
|
<table class="table table-striped table-hover table-sm">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2022-05-04 18:02:18 +02:00
|
|
|
<th scope="col" style="width: 60%">Rule</th>
|
|
|
|
<th scope="col" style="width: 20%" class="text-center" title="How many samples were produced by the rule">Samples</th>
|
|
|
|
<th scope="col" style="width: 20%" class="text-center" title="How many seconds ago rule was executed">Updated</th>
|
2021-09-07 21:39:22 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2022-03-15 12:54:53 +01:00
|
|
|
{% for _, r := range g.Rules %}
|
|
|
|
<tr{% if r.LastError != "" %} class="alert-danger"{% endif %}>
|
2021-09-07 21:39:22 +02:00
|
|
|
<td>
|
2022-05-04 18:02:18 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-12 mb-2">
|
|
|
|
{% if r.Type == "alerting" %}
|
|
|
|
<b>alert:</b> {%s r.Name %} (for: {%v r.Duration %} seconds)
|
|
|
|
{% else %}
|
|
|
|
<b>record:</b> {%s r.Name %}
|
|
|
|
{% endif %}
|
2022-09-14 14:04:24 +02:00
|
|
|
| <span><a target="_blank" href="{%s prefix+r.WebLink() %}">Details</a></span>
|
2022-05-04 18:02:18 +02:00
|
|
|
</div>
|
|
|
|
<div class="col-12">
|
|
|
|
<code><pre>{%s r.Query %}</pre></code>
|
|
|
|
</div>
|
|
|
|
<div class="col-12 mb-2">
|
|
|
|
{% if len(r.Labels) > 0 %} <b>Labels:</b>{% endif %}
|
|
|
|
{% for k, v := range r.Labels %}
|
|
|
|
<span class="ms-1 badge bg-primary">{%s k %}={%s v %}</span>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% if r.LastError != "" %}
|
|
|
|
<div class="col-12">
|
|
|
|
<b>Error:</b>
|
|
|
|
<div class="error-cell">
|
|
|
|
{%s r.LastError %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
2021-09-07 21:39:22 +02:00
|
|
|
</td>
|
2022-05-04 18:02:18 +02:00
|
|
|
<td class="text-center">{%d r.LastSamples %}</td>
|
|
|
|
<td class="text-center">{%f.3 time.Since(r.LastEvaluation).Seconds() %}s ago</td>
|
2021-09-07 21:39:22 +02:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
<div>
|
2022-09-14 14:04:24 +02:00
|
|
|
<p>No groups...</p>
|
2021-09-07 21:39:22 +02:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Footer(r) %}
|
2021-09-07 21:39:22 +02:00
|
|
|
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{% func ListAlerts(r *http.Request, groupAlerts []GroupAlerts) %}
|
2022-07-08 10:26:13 +02:00
|
|
|
{%code prefix := utils.Prefix(r.URL.Path) %}
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Header(r, navItems, "Alerts") %}
|
2021-09-07 21:39:22 +02:00
|
|
|
{% if len(groupAlerts) > 0 %}
|
|
|
|
<a class="btn btn-primary" role="button" onclick="collapseAll()">Collapse All</a>
|
|
|
|
<a class="btn btn-primary" role="button" onclick="expandAll()">Expand All</a>
|
|
|
|
{% for _, ga := range groupAlerts %}
|
|
|
|
{%code g := ga.Group %}
|
|
|
|
<div class="group-heading alert-danger" data-bs-target="rules-{%s g.ID %}">
|
|
|
|
<span class="anchor" id="group-{%s g.ID %}"></span>
|
|
|
|
<a href="#group-{%s g.ID %}">{%s g.Name %}{% if g.Type != "prometheus" %} ({%s g.Type %}){% endif %}</a>
|
|
|
|
<span class="badge bg-danger" title="Number of active alerts">{%d len(ga.Alerts) %}</span>
|
|
|
|
<br>
|
|
|
|
<p class="fs-6 fw-lighter">{%s g.File %}</p>
|
|
|
|
</div>
|
|
|
|
{%code
|
|
|
|
var keys []string
|
|
|
|
alertsByRule := make(map[string][]*APIAlert)
|
|
|
|
for _, alert := range ga.Alerts {
|
|
|
|
if len(alertsByRule[alert.RuleID]) < 1 {
|
|
|
|
keys = append(keys, alert.RuleID)
|
|
|
|
}
|
|
|
|
alertsByRule[alert.RuleID] = append(alertsByRule[alert.RuleID], alert)
|
|
|
|
}
|
|
|
|
sort.Strings(keys)
|
|
|
|
%}
|
|
|
|
<div class="collapse" id="rules-{%s g.ID %}">
|
|
|
|
{% for _, ruleID := range keys %}
|
|
|
|
{%code
|
|
|
|
defaultAR := alertsByRule[ruleID][0]
|
|
|
|
var labelKeys []string
|
|
|
|
for k := range defaultAR.Labels {
|
|
|
|
labelKeys = append(labelKeys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(labelKeys)
|
|
|
|
%}
|
|
|
|
<br>
|
2021-10-13 14:25:11 +02:00
|
|
|
<b>alert:</b> {%s defaultAR.Name %} ({%d len(alertsByRule[ruleID]) %})
|
|
|
|
| <span><a target="_blank" href="{%s defaultAR.SourceLink %}">Source</a></span>
|
|
|
|
<br>
|
2021-09-07 21:39:22 +02:00
|
|
|
<b>expr:</b><code><pre>{%s defaultAR.Expression %}</pre></code>
|
|
|
|
<table class="table table-striped table-hover table-sm">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th scope="col">Labels</th>
|
|
|
|
<th scope="col">State</th>
|
|
|
|
<th scope="col">Active at</th>
|
|
|
|
<th scope="col">Value</th>
|
|
|
|
<th scope="col">Link</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for _, ar := range alertsByRule[ruleID] %}
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
{% for _, k := range labelKeys %}
|
|
|
|
<span class="ms-1 badge bg-primary">{%s k %}={%s ar.Labels[k] %}</span>
|
|
|
|
{% endfor %}
|
|
|
|
</td>
|
2021-10-22 11:30:38 +02:00
|
|
|
<td>{%= badgeState(ar.State) %}</td>
|
|
|
|
<td>
|
|
|
|
{%s ar.ActiveAt.Format("2006-01-02T15:04:05Z07:00") %}
|
|
|
|
{% if ar.Restored %}{%= badgeRestored() %}{% endif %}
|
|
|
|
</td>
|
2021-09-07 21:39:22 +02:00
|
|
|
<td>{%s ar.Value %}</td>
|
|
|
|
<td>
|
2022-07-08 10:26:13 +02:00
|
|
|
<a href="{%s prefix+ar.WebLink() %}">Details</a>
|
2021-09-07 21:39:22 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
<div>
|
2022-09-14 14:04:24 +02:00
|
|
|
<p>No active alerts...</p>
|
2021-09-07 21:39:22 +02:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Footer(r) %}
|
2021-09-07 21:39:22 +02:00
|
|
|
|
|
|
|
{% endfunc %}
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{% func ListTargets(r *http.Request, targets map[notifier.TargetType][]notifier.Target) %}
|
|
|
|
{%= tpl.Header(r, navItems, "Notifiers") %}
|
2022-02-02 13:11:41 +01:00
|
|
|
{% if len(targets) > 0 %}
|
|
|
|
<a class="btn btn-primary" role="button" onclick="collapseAll()">Collapse All</a>
|
|
|
|
<a class="btn btn-primary" role="button" onclick="expandAll()">Expand All</a>
|
|
|
|
|
|
|
|
{%code
|
|
|
|
var keys []string
|
|
|
|
for key := range targets {
|
|
|
|
keys = append(keys, string(key))
|
|
|
|
}
|
|
|
|
sort.Strings(keys)
|
|
|
|
%}
|
|
|
|
|
|
|
|
{% for i := range keys %}
|
|
|
|
{%code typeK, ns := keys[i], targets[notifier.TargetType(keys[i])]
|
|
|
|
count := len(ns)
|
|
|
|
%}
|
|
|
|
<div class="group-heading data-bs-target="rules-{%s typeK %}">
|
|
|
|
<span class="anchor" id="notifiers-{%s typeK %}"></span>
|
|
|
|
<a href="#notifiers-{%s typeK %}">{%s typeK %} ({%d count %})</a>
|
|
|
|
</div>
|
|
|
|
<div class="collapse show" id="notifiers-{%s typeK %}">
|
|
|
|
<table class="table table-striped table-hover table-sm">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th scope="col">Labels</th>
|
|
|
|
<th scope="col">Address</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for _, n := range ns %}
|
|
|
|
<tr>
|
|
|
|
<td>
|
2022-11-30 06:22:12 +01:00
|
|
|
{% for _, l := range n.Labels.GetLabels() %}
|
2022-02-02 13:11:41 +01:00
|
|
|
<span class="ms-1 badge bg-primary">{%s l.Name %}={%s l.Value %}</span>
|
|
|
|
{% endfor %}
|
|
|
|
</td>
|
|
|
|
<td>{%s n.Notifier.Addr() %}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
<div>
|
2022-09-14 14:04:24 +02:00
|
|
|
<p>No targets...</p>
|
2022-02-02 13:11:41 +01:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Footer(r) %}
|
2022-02-02 13:11:41 +01:00
|
|
|
|
|
|
|
{% endfunc %}
|
|
|
|
|
2022-07-06 10:46:01 +02:00
|
|
|
{% func Alert(r *http.Request, alert *APIAlert) %}
|
2022-07-08 10:26:13 +02:00
|
|
|
{%code prefix := utils.Prefix(r.URL.Path) %}
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Header(r, navItems, "") %}
|
2021-09-07 21:39:22 +02:00
|
|
|
{%code
|
|
|
|
var labelKeys []string
|
|
|
|
for k := range alert.Labels {
|
|
|
|
labelKeys = append(labelKeys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(labelKeys)
|
|
|
|
|
|
|
|
var annotationKeys []string
|
|
|
|
for k := range alert.Annotations {
|
|
|
|
annotationKeys = append(annotationKeys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(annotationKeys)
|
|
|
|
%}
|
2022-09-14 14:04:24 +02:00
|
|
|
<div class="display-6 pb-3 mb-3">Alert: {%s alert.Name %}<span class="ms-2 badge {% if alert.State=="firing" %}bg-danger{% else %} bg-warning text-dark{% endif %}">{%s alert.State %}</span></div>
|
2021-09-07 21:39:22 +02:00
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Active at
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{%s alert.ActiveAt.Format("2006-01-02T15:04:05Z07:00") %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Expr
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<code><pre>{%s alert.Expression %}</pre></code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Labels
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{% for _, k := range labelKeys %}
|
|
|
|
<span class="m-1 badge bg-primary">{%s k %}={%s alert.Labels[k] %}</span>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Annotations
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{% for _, k := range annotationKeys %}
|
|
|
|
<b>{%s k %}:</b><br>
|
|
|
|
<p>{%s alert.Annotations[k] %}</p>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Group
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
2022-07-08 10:26:13 +02:00
|
|
|
<a target="_blank" href="{%s prefix %}groups#group-{%s alert.GroupID %}">{%s alert.GroupID %}</a>
|
2021-09-07 21:39:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-13 14:25:11 +02:00
|
|
|
</div>
|
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Source link
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<a target="_blank" href="{%s alert.SourceLink %}">Link</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-07 21:39:22 +02:00
|
|
|
</div>
|
2022-07-06 10:46:01 +02:00
|
|
|
{%= tpl.Footer(r) %}
|
2021-09-07 21:39:22 +02:00
|
|
|
|
2021-10-22 11:30:38 +02:00
|
|
|
{% endfunc %}
|
|
|
|
|
2022-09-14 14:04:24 +02:00
|
|
|
|
|
|
|
{% func RuleDetails(r *http.Request, rule APIRule) %}
|
|
|
|
{%code prefix := utils.Prefix(r.URL.Path) %}
|
|
|
|
{%= tpl.Header(r, navItems, "") %}
|
|
|
|
{%code
|
|
|
|
var labelKeys []string
|
|
|
|
for k := range rule.Labels {
|
|
|
|
labelKeys = append(labelKeys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(labelKeys)
|
|
|
|
|
|
|
|
var annotationKeys []string
|
|
|
|
for k := range rule.Annotations {
|
|
|
|
annotationKeys = append(annotationKeys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(annotationKeys)
|
|
|
|
%}
|
|
|
|
<div class="display-6 pb-3 mb-3">Rule: {%s rule.Name %}<span class="ms-2 badge {% if rule.Health!="ok" %}bg-danger{% else %} bg-warning text-dark{% endif %}">{%s rule.Health %}</span></div>
|
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Expr
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<code><pre>{%s rule.Query %}</pre></code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-15 16:15:39 +02:00
|
|
|
{% if rule.Type == "alerting" %}
|
2022-09-14 14:04:24 +02:00
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
For
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{%v rule.Duration %} seconds
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-15 16:15:39 +02:00
|
|
|
{% endif %}
|
2022-09-14 14:04:24 +02:00
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Labels
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{% for _, k := range labelKeys %}
|
|
|
|
<span class="m-1 badge bg-primary">{%s k %}={%s rule.Labels[k] %}</span>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-15 16:15:39 +02:00
|
|
|
{% if rule.Type == "alerting" %}
|
2022-09-14 14:04:24 +02:00
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Annotations
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{% for _, k := range annotationKeys %}
|
|
|
|
<b>{%s k %}:</b><br>
|
|
|
|
<p>{%s rule.Annotations[k] %}</p>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-08 14:34:03 +01:00
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Debug
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
{%v rule.Debug %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-15 16:15:39 +02:00
|
|
|
{% endif %}
|
2022-09-14 14:04:24 +02:00
|
|
|
<div class="container border-bottom p-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
|
|
Group
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<a target="_blank" href="{%s prefix %}groups#group-{%s rule.GroupID %}">{%s rule.GroupID %}</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br>
|
2022-12-29 12:36:44 +01:00
|
|
|
<div class="display-6 pb-3">Last {%d len(rule.Updates) %}/{%d rule.MaxUpdates %} updates</span>:</div>
|
2022-09-14 14:04:24 +02:00
|
|
|
<table class="table table-striped table-hover table-sm">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2022-09-15 12:40:22 +02:00
|
|
|
<th scope="col" title="The time when event was created">Updated at</th>
|
|
|
|
<th scope="col" style="width: 10%" class="text-center" title="How many samples were returned">Samples</th>
|
|
|
|
<th scope="col" style="width: 10%" class="text-center" title="How many seconds request took">Duration</th>
|
|
|
|
<th scope="col" class="text-center" title="Time used for rule execution">Executed at</th>
|
|
|
|
<th scope="col" class="text-center" title="cURL command with request example">cURL</th>
|
2022-09-14 14:04:24 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
|
|
|
|
{% for _, u := range rule.Updates %}
|
|
|
|
<tr{% if u.err != nil %} class="alert-danger"{% endif %}>
|
|
|
|
<td>
|
|
|
|
<span class="badge bg-primary rounded-pill me-3" title="Updated at">{%s u.time.Format(time.RFC3339) %}</span>
|
|
|
|
</td>
|
2022-09-15 12:40:22 +02:00
|
|
|
<td class="text-center" wi>{%d u.samples %}</td>
|
2022-09-14 14:04:24 +02:00
|
|
|
<td class="text-center">{%f.3 u.duration.Seconds() %}s</td>
|
|
|
|
<td class="text-center">{%s u.at.Format(time.RFC3339) %}</td>
|
2022-09-15 12:40:22 +02:00
|
|
|
<td>
|
2022-12-09 16:13:29 +01:00
|
|
|
<textarea class="curl-area" rows="1" onclick="this.focus();this.select()">{%s u.curl %}</textarea>
|
2022-09-15 12:40:22 +02:00
|
|
|
</td>
|
2022-09-14 14:04:24 +02:00
|
|
|
</tr>
|
|
|
|
</li>
|
|
|
|
{% if u.err != nil %}
|
|
|
|
<tr{% if u.err != nil %} class="alert-danger"{% endif %}>
|
2022-09-15 12:40:22 +02:00
|
|
|
<td colspan="5">
|
2022-09-14 14:04:24 +02:00
|
|
|
<span class="alert-danger">{%v u.err %}</span>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{%= tpl.Footer(r) %}
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-22 11:30:38 +02:00
|
|
|
{% func badgeState(state string) %}
|
|
|
|
{%code
|
|
|
|
badgeClass := "bg-warning text-dark"
|
|
|
|
if state == "firing" {
|
|
|
|
badgeClass = "bg-danger"
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
<span class="badge {%s badgeClass %}">{%s state %}</span>
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func badgeRestored() %}
|
|
|
|
<span class="badge bg-warning text-dark" title="Alert state was restored after the service restart from remote storage">restored</span>
|
2022-05-02 09:06:34 +02:00
|
|
|
{% endfunc %}
|