Lists that were cut off by a fixed LIMIT, or could grow without bound, are paged by keyset: the cursor holds the sort key and an ID, so pages neither skip nor repeat items as others are added. The audit logs had a timestamp-only cursor that could skip entries with equal times. The API returns at most 100 items per list (limit takes up to 500) with next_cursor and prev_cursor, passed back as after and before. The console shows Newer/Older (or Previous/Next) links and To the start, without JavaScript. Paged: incidents (optionally of one monitor), a monitor's results and evidence, a checker's results, the audit logs, members, maintenance windows, firing Alertmanager alerts, the monitors API and the admin lists of status pages and organizations, which move to their own admin pages. A monitor's page shows its latest incidents and results and links to all of them. The dashboard caps every group at 50 of its own monitors with a link to a paged view of the group, and gains a search by name or target. Lists filtered by permission after reading may show fewer items on a page. Closes #116 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
119 lines
4.1 KiB
Templ
119 lines
4.1 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
|
|
Pager Pager
|
|
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>
|
|
}
|
|
@pager(v.Pager, "newer", "older")
|
|
</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`
|