Organizations create receiver URLs for Alertmanager's webhook (token in the path or as bearer). A monitor of type alertmanager is down while an alert matching all its label matchers fires, and goes through the usual evaluation, so confirmations, maintenance, notifications and SLA apply. Results are recorded when the state changes and once per interval; alerts Alertmanager stops repeating end after the monitor's stale period, so a lost resolve cannot hold it down. An overview lists firing alerts with the monitors following them and creates a prefilled monitor for the others. Closes #91 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
117 lines
4.0 KiB
Templ
117 lines
4.0 KiB
Templ
package web
|
|
|
|
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
|
|
|
// AlertmanagerView is the Alertmanager settings page.
|
|
type AlertmanagerView struct {
|
|
Receivers []ReceiverRow
|
|
Alerts []AlertRow
|
|
CanManage bool
|
|
}
|
|
|
|
// ReceiverRow is a webhook endpoint for Alertmanager.
|
|
type ReceiverRow struct {
|
|
ID string
|
|
Name string
|
|
Prefix string
|
|
Created string
|
|
LastSeen string
|
|
}
|
|
|
|
// AlertRow is a firing alert.
|
|
type AlertRow struct {
|
|
Name string
|
|
Summary string
|
|
Labels [][2]string
|
|
Since string
|
|
Monitors []CheckerLink
|
|
CreateURL string
|
|
}
|
|
|
|
templ AlertmanagerPage(p Page, me Me, v AlertmanagerView) {
|
|
@consoleShell(p, me) {
|
|
@settingsHeading("alertmanager.title", "alertmanager.intro")
|
|
<section class="mb-12">
|
|
@sectionHeading("alertmanager.firing")
|
|
if len(v.Alerts) == 0 {
|
|
<p class="text-sm text-muted">{ i18n.T(ctx, "alertmanager.no_alerts") }</p>
|
|
} else {
|
|
<ul class="divide-y divide-rule border-y border-rule text-sm">
|
|
for _, a := range v.Alerts {
|
|
<li class="grid gap-2 py-3 sm:grid-cols-[1fr_auto]">
|
|
<div class="min-w-0">
|
|
<div class="flex items-center gap-2">
|
|
@statusDot(StatusDown)
|
|
<span class="font-medium">{ a.Name }</span>
|
|
<span class="font-mono text-xs text-muted">{ i18n.T(ctx, "alertmanager.since", "Time", a.Since) }</span>
|
|
</div>
|
|
if a.Summary != "" {
|
|
<p class="ml-4 mt-0.5 text-muted">{ a.Summary }</p>
|
|
}
|
|
<p class="ml-4 mt-1 flex flex-wrap gap-1">
|
|
for _, l := range a.Labels {
|
|
<span class="border border-rule px-1.5 font-mono text-xs">{ l[0] + "=" + l[1] }</span>
|
|
}
|
|
</p>
|
|
</div>
|
|
<div class="text-sm sm:text-right">
|
|
if len(a.Monitors) == 0 {
|
|
<a href={ templ.SafeURL(a.CreateURL) } class="border border-ink px-2.5 py-1 hover:bg-ink hover:text-paper">{ i18n.T(ctx, "alertmanager.create_monitor") }</a>
|
|
} else {
|
|
for _, m := range a.Monitors {
|
|
<a href={ templ.SafeURL(m.URL) } class="block hover:underline">{ m.Label }</a>
|
|
}
|
|
}
|
|
</div>
|
|
</li>
|
|
}
|
|
</ul>
|
|
}
|
|
</section>
|
|
if v.CanManage {
|
|
<section class="max-w-2xl">
|
|
@sectionHeading("alertmanager.receivers")
|
|
if len(v.Receivers) > 0 {
|
|
<ul class="mb-6 divide-y divide-rule border-y border-rule text-sm">
|
|
for _, r := range v.Receivers {
|
|
<li class="flex items-center justify-between gap-4 py-2">
|
|
<span>
|
|
{ r.Name }
|
|
<span class="font-mono text-xs text-muted">{ r.Prefix }…</span>
|
|
</span>
|
|
<span class="flex items-center gap-4">
|
|
<span class="font-mono text-xs text-muted">{ i18n.T(ctx, "alertmanager.last_received", "Time", r.LastSeen) }</span>
|
|
<button type="button" data-delete={ "/org/alertmanager/receivers/" + r.ID } data-confirm={ i18n.T(ctx, "alertmanager.delete_confirm") } data-next="/settings/alertmanager" class="text-muted hover:text-down">{ i18n.T(ctx, "common.delete") }</button>
|
|
</span>
|
|
</li>
|
|
}
|
|
</ul>
|
|
}
|
|
<form data-api="/org/alertmanager/receivers" data-show-link>
|
|
@formError()
|
|
@valueField(i18n.T(ctx, "sso.field.name"), "name", "", "Prometheus prod", true)
|
|
@submit(i18n.T(ctx, "alertmanager.create_receiver"))
|
|
<div data-link-output hidden class="mt-6 border border-ink p-4">
|
|
<p class="mb-2 text-sm">{ i18n.T(ctx, "alertmanager.copy_now") }</p>
|
|
<input data-link readonly class="w-full border border-rule bg-transparent px-2 py-1.5 font-mono text-xs"/>
|
|
</div>
|
|
</form>
|
|
<p class="mb-2 mt-6 text-sm">{ i18n.T(ctx, "alertmanager.config_hint") }</p>
|
|
<pre class="overflow-x-auto border border-rule px-3 py-2 font-mono text-xs leading-relaxed">{ alertmanagerExample }</pre>
|
|
</section>
|
|
}
|
|
}
|
|
}
|
|
|
|
// alertmanagerExample is the alertmanager.yml snippet shown to users.
|
|
const alertmanagerExample = `receivers:
|
|
- name: uptimesebi
|
|
webhook_configs:
|
|
- url: https://<your installation>/am/uam_…
|
|
send_resolved: true
|
|
|
|
route:
|
|
routes:
|
|
- receiver: uptimesebi
|
|
continue: true`
|