1140d773f8
Release / build (amd64, darwin) (push) Failing after 9s
Release / build (arm64, darwin) (push) Failing after 10s
Release / build (amd64, linux) (push) Failing after 10s
Release / release (push) Has been skipped
Release / build (arm64, linux) (push) Failing after 11s
terdut-server v0.4.0 splits the alerts row into two objects, and the
endpoints this client drove for acknowledgement, comments and archiving
are gone. Pointing the same screens at the new paths would have missed
the point of the split: alerts are now Alertmanager's record, read-only
and carrying no human state, while the incident is the thing anyone
actually works on.
Incidents lead the section list and are what the client opens on. The
queue shows severity, status, assignee and age, and the detail view adds
what only exists server-side now: the group labels Alertmanager
correlated on, the member alerts, and an append-only timeline where
system events and notes are interleaved. That timeline is the whole
history the server keeps — alert rows are still mutated in place — so
rendering it in order matters more than styling it.
Actions all move onto the incident: a/A acknowledge, s assign, z/Z
snooze, c note, d delete note, x archive, R resolve.
Two of those need care rather than a keybinding:
- R, not r, resolves, and it asks first. The server treats a manual
resolve as terminal: a later occurrence opens a new incident instead
of reopening this one, and an alert that never stops firing leaves
the incident closed for good. A stray keypress is not recoverable,
so the prompt says what it means.
- x refuses on an open incident rather than archiving it, since
archiving unresolved work only hides it. Snooze is offered as the
"not now" answer, and the client treats a snoozed_until in the past
as not snoozed, matching the server, which sweeps nothing.
Statistics lead with MTTA and MTTR, neither of which was computable
before. The server sends null until something has actually been
acknowledged or resolved, and that renders as — rather than 0: no data
is a different claim from instant.
Alerts keep a tab of their own as the raw feed — useful for asking what
Alertmanager is really sending — with an Incident column replacing Ack
By, and i in the detail view jumping to the incident where something can
be done about it. Archived now holds archived incidents; archiving an
alert is server-side housekeeping and no longer a user action.
BREAKING CHANGE: requires terdut-server v0.4.0 or later. Against an
older server every incident request 404s. Use terdut-tui v0.3.x with
servers before v0.4.0.
100 lines
3.0 KiB
Go
100 lines
3.0 KiB
Go
package tui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
"github.com/yeniklas/terdut-tui/internal/api"
|
|
)
|
|
|
|
var (
|
|
colorPrimary = lipgloss.Color("69") // blue
|
|
colorMuted = lipgloss.Color("240") // gray
|
|
colorFiring = lipgloss.Color("196") // red
|
|
colorResolved = lipgloss.Color("70") // green
|
|
colorAccent = lipgloss.Color("214") // orange
|
|
|
|
colorSevCritical = lipgloss.Color("196") // red
|
|
colorSevError = lipgloss.Color("202") // dark orange
|
|
colorSevWarning = lipgloss.Color("214") // orange
|
|
colorSevInfo = lipgloss.Color("39") // cyan
|
|
|
|
styleHeader = lipgloss.NewStyle().
|
|
Bold(true).
|
|
Foreground(colorPrimary).
|
|
Padding(0, 1)
|
|
|
|
styleTabActive = lipgloss.NewStyle().
|
|
Bold(true).
|
|
Foreground(lipgloss.Color("0")).
|
|
Background(colorPrimary).
|
|
Padding(0, 2)
|
|
|
|
styleTabInactive = lipgloss.NewStyle().
|
|
Foreground(colorMuted).
|
|
Padding(0, 2)
|
|
|
|
styleFooter = lipgloss.NewStyle().
|
|
Foreground(colorMuted)
|
|
|
|
styleStatus = lipgloss.NewStyle().
|
|
Foreground(colorAccent).
|
|
Bold(true)
|
|
|
|
styleError = lipgloss.NewStyle().
|
|
Foreground(colorFiring).
|
|
Bold(true)
|
|
|
|
styleFiring = lipgloss.NewStyle().Foreground(colorFiring).Bold(true)
|
|
styleResolved = lipgloss.NewStyle().Foreground(colorResolved)
|
|
styleMuted = lipgloss.NewStyle().Foreground(colorMuted)
|
|
styleAlertName = lipgloss.NewStyle().Bold(true)
|
|
styleBold = lipgloss.NewStyle().Bold(true)
|
|
styleSelected = lipgloss.NewStyle().Foreground(colorPrimary).Bold(true)
|
|
styleAccent = lipgloss.NewStyle().Foreground(colorAccent)
|
|
|
|
// Incident status. Triggered is unclaimed work and reads as loudly as a
|
|
// firing alert; acknowledged means somebody has it.
|
|
styleTriggered = lipgloss.NewStyle().Foreground(colorFiring).Bold(true)
|
|
styleAcknowledged = lipgloss.NewStyle().Foreground(colorAccent).Bold(true)
|
|
styleSnoozed = lipgloss.NewStyle().Foreground(colorMuted).Italic(true)
|
|
|
|
// Severity, over the conventional Alertmanager label values.
|
|
styleSevCritical = lipgloss.NewStyle().Foreground(colorSevCritical).Bold(true)
|
|
styleSevError = lipgloss.NewStyle().Foreground(colorSevError).Bold(true)
|
|
styleSevWarning = lipgloss.NewStyle().Foreground(colorSevWarning)
|
|
styleSevInfo = lipgloss.NewStyle().Foreground(colorSevInfo)
|
|
)
|
|
|
|
// severityStyle picks the style for a severity label, falling back to muted for
|
|
// values this client does not recognise rather than dropping them.
|
|
func severityStyle(severity string) lipgloss.Style {
|
|
switch strings.ToLower(severity) {
|
|
case "critical":
|
|
return styleSevCritical
|
|
case "error":
|
|
return styleSevError
|
|
case "warning":
|
|
return styleSevWarning
|
|
case "info":
|
|
return styleSevInfo
|
|
default:
|
|
return styleMuted
|
|
}
|
|
}
|
|
|
|
// incidentStatusStyle picks the style for an incident status, falling back to
|
|
// muted for statuses added after this client was built.
|
|
func incidentStatusStyle(status string) lipgloss.Style {
|
|
switch status {
|
|
case api.StatusTriggered:
|
|
return styleTriggered
|
|
case api.StatusAcknowledged:
|
|
return styleAcknowledged
|
|
case api.StatusResolved:
|
|
return styleResolved
|
|
default:
|
|
return styleMuted
|
|
}
|
|
}
|