Documentation
¶
Overview ¶
Package groups is the Alert Group lifecycle (C-09, ADR-0003, ADR-0004, ADR-0016): grouping of newly firing Alerts, the state machine with its system transitions, the Timeline with the lifecycle events, and the reads of one Alert Group. Every change of an Alert Group passes through the dispatcher; only this package writes alert_groups, alert_group_alerts, timeline_entries, notes and alert_group_counters (lint 2).
Index ¶
- Constants
- Variables
- func ParseWeekStart(s string) (time.Weekday, error)
- func Range(from, to *time.Time, now time.Time) (time.Time, time.Time, error)
- func RecordSystemEntry(ctx context.Context, db DBTX, e SystemEntry) error
- func RetentionTask(q Queries) func(ctx context.Context, orgID int64, now time.Time) (int64, int64, error)
- func SnoozePresetEnd(p SnoozePreset, now time.Time, loc *time.Location, start WorkdayStart, ...) (time.Time, error)
- func StatusReasonCode(reason string) string
- type Actor
- type ActorRef
- type AlertFilter
- type AlertPage
- type AlertPosition
- type BulkItem
- type BulkOutcome
- type BulkRequest
- type Caller
- type Command
- type Config
- type Counts
- type DBTX
- type DeliveryView
- type DurationStats
- type Event
- type FieldError
- type Filter
- type ForbiddenError
- type Group
- type GroupAlert
- type GroupRef
- type Kind
- type Link
- type Linker
- type ListPage
- type ListPosition
- type ListRequest
- type Loudness
- type Mention
- type NextNotice
- type NotePage
- type NotePosition
- type NoteView
- type Notice
- type Outcome
- type PresetEnd
- type PresetList
- type Prior
- type Purged
- type Queries
- type Recorded
- type Ref
- type RefusedError
- type Related
- type RelatedPage
- type ReminderCheck
- type Rendering
- type Requester
- type Rerender
- type Resolution
- type Restamp
- type Result
- type Row
- type Service
- func (s *Service) Acknowledge(ctx context.Context, c Caller, publicID string) (Result, error)
- func (s *Service) AddNote(ctx context.Context, c Caller, publicID, body string) (NoteView, error)
- func (s *Service) AlertChanges(ctx context.Context, tx ingestdb.DBTX, changes []ingest.AlertChange) (ingest.Routed, error)
- func (s *Service) Alerts(ctx context.Context, publicID string, f AlertFilter) (AlertPage, error)
- func (s *Service) AnswerReminder(ctx context.Context, c Caller, publicID string) (Result, error)
- func (s *Service) Bulk(ctx context.Context, c Caller, r BulkRequest) ([]BulkItem, error)
- func (s *Service) Counts(ctx context.Context, f Filter) (Counts, error)
- func (s *Service) EndGracePeriod(ctx context.Context, tx dbgen.DBTX, groupID int64) (ingest.Routed, error)
- func (s *Service) EndReopenWindow(ctx context.Context, tx dbgen.DBTX, groupID int64) error
- func (s *Service) EndSnooze(ctx context.Context, tx dbgen.DBTX, groupID int64) (func(context.Context), error)
- func (s *Service) ExportGauges(ctx context.Context) error
- func (s *Service) FireAckTimeout(ctx context.Context, tx dbgen.DBTX, groupID int64) (func(context.Context), error)
- func (s *Service) FireReminder(ctx context.Context, tx dbgen.DBTX, groupID int64, deadline time.Time) (func(context.Context), error)
- func (s *Service) Get(ctx context.Context, publicID string) (View, error)
- func (s *Service) List(ctx context.Context, r ListRequest) (ListPage, error)
- func (s *Service) MarkPublished(ctx context.Context, groupID int64, at time.Time) error
- func (s *Service) MoveOpenAlertGroups(ctx context.Context, r Requester, publicID string) (int, error)
- func (s *Service) Notes(ctx context.Context, publicID string, after *NotePosition, limit int) (NotePage, error)
- func (s *Service) OpenCounts(ctx context.Context, integrations []string) (map[string]int64, error)
- func (s *Service) RecordDowntime(ctx context.Context, tx dbgen.DBTX, from, to time.Time) error
- func (s *Service) Related(ctx context.Context, publicID string, after *ListPosition, limit int) (RelatedPage, error)
- func (s *Service) ReleaseOwner(ctx context.Context, tx usersdb.DBTX, userID int64, reason string) (func(context.Context), error)
- func (s *Service) Resolve(ctx context.Context, c Caller, publicID string, note *string) (Result, error)
- func (s *Service) SetLinks(l Linker)
- func (s *Service) SetReminderReached(f ReminderCheck)
- func (s *Service) SetRerender(r Rerender)
- func (s *Service) Snooze(ctx context.Context, c Caller, publicID string, end SnoozeEnd) (Result, error)
- func (s *Service) SnoozePresets(ctx context.Context, c Caller, timeZone string) (PresetList, error)
- func (s *Service) Statistics(ctx context.Context, r StatisticsRequest) (Statistics, error)
- func (s *Service) Timeline(ctx context.Context, publicID string, f TimelineFilter) (TimelinePage, error)
- func (s *Service) Unacknowledge(ctx context.Context, c Caller, publicID string) (Result, error)
- func (s *Service) Unresolve(ctx context.Context, c Caller, publicID string) (Result, error)
- func (s *Service) Unsnooze(ctx context.Context, c Caller, publicID string) (Result, error)
- type SnoozeEnd
- type SnoozePreset
- type Sort
- type Statistics
- type StatisticsDay
- type StatisticsItem
- type StatisticsRequest
- type Status
- type Store
- type SystemEntry
- type SystemEvent
- type TemplateFailure
- type TimelineActor
- type TimelineEntry
- type TimelineFilter
- type TimelinePage
- type TimelinePosition
- type Variant
- type View
- type WorkdayStart
Constants ¶
const ( PermissionAcknowledge auth.Permission = "alert-groups:acknowledge" PermissionResolve auth.Permission = "alert-groups:resolve" PermissionSnooze auth.Permission = "alert-groups:snooze" PermissionNote auth.Permission = "alert-groups:note" )
The Permissions of the Commands (reference.md, Permissions).
const ( ActionAcknowledged = "alert_group.acknowledged" ActionTakenOver = "alert_group.taken_over" ActionUnacknowledged = "alert_group.unacknowledged" ActionResolved = "alert_group.resolved" ActionUnresolved = "alert_group.unresolved" ActionSnoozed = "alert_group.snoozed" ActionUnsnoozed = "alert_group.unsnoozed" ActionNoteAdded = "alert_group.note_added" // ActionReminderAnswered is "Still on it" (C-17.FR-10). ActionReminderAnswered = "alert_group.reminder_answered" )
The Audit log actions of the Commands (C-10.FR-12).
const ( CodeAlreadyResolved = "already_resolved" CodeNotAcknowledged = "not_acknowledged" CodeNotSnoozed = "not_snoozed" CodeNotResolved = "not_resolved" CodeAllAlertsResolved = "all_alerts_resolved" CodeResolvedAutomatically = "resolved_automatically" CodeNewerGroupExists = "newer_alert_group_exists" CodeOwnerMustBeUser = "owner_must_be_user" CodeRouteDeleted = "route_deleted" CodeForbidden = "forbidden" CodeOwnedByOther = "owned_by_other" CodeNotFound = "not_found" CodeNotOwner = "not_owner" CodeNoReminderPending = "no_reminder_pending" )
The refusal codes of command-refused (C-10.FR-2), forbidden for a missing Permission, and the codes of the other outcomes of a bulk command.
const ( CodeRequired = "required" CodeOneOfRequired = "one_of_required" )
The field codes of the requests of Commands.
const ( ResolvedByUser = "user" ResolvedBySystem = "system" )
The kinds of who resolved an Alert Group.
const ( TimerReopenWindowEnd = "reopen_window_end" TimerGracePeriodEnd = "grace_period_end" TimerSnoozeEnd = "snooze_end" )
The timer kinds of this capability.
const ( CodeUnknownID = "unknown_id" CodeOutOfRange = "out_of_range" CodeInvalid = "invalid_format" CodeUnsupported = "unsupported" )
The field codes of FieldError.
const ( OwnerMe = "me" OwnerNone = "none" )
The values of Filter.Owner that name no User.
const ( NoticeAlertsStillFiring = "alerts_still_firing" NoticeReplacement = "replacement" NoticeFiringAgainAfterManualResolve = "firing_again_after_manual_resolve" NoticeDetailsRemoved = "details_removed" NoticeNewerAlertGroupExists = "newer_alert_group_exists" )
The notices of the Alert Group page (AlertGroupNotice).
const ( ReasonOwnerDisabled = "owner_disabled" ReasonOwnerDeleted = "owner_deleted" )
The reasons of the release of an Owner who was disabled or deleted (C-03.FR-13, C-09.FR-22).
const ( ByRoute = "route" ByIntegration = "integration" )
The subjects of the statistics (group_by).
const ( TimerAckTimeout = "ack_timeout" TimerReminder = "reminder" )
The timer kinds of the ack timeout and the Reminders (C-17).
const ( ReasonNoAnswer = "No answer to the last two Reminders" ReasonCodeNoAnswer = "reminders_unanswered" )
ReasonNoAnswer is the reason of an auto_unacknowledged entry (C-17.FR-5); ReasonCodeNoAnswer is its code.
const ActionOpenAlertGroupsMoved = "route.open_alert_groups_moved"
ActionOpenAlertGroupsMoved is the Audit log action of moveOpenAlertGroups.
const BulkMax = 100
BulkMax is alert_group.bulk_max: the most Alert Groups of one bulk command.
const CodeTooLong = "too_long"
CodeTooLong is the field code of a Note longer than NoteMaxLength.
const ListRange = 7 * 24 * time.Hour
ListRange is alert_group.list_range: the time range of the list, the counts and the statistics when none is given.
const NoteMaxLength = 4000
NoteMaxLength is alert_group.note_max_length: the most characters of a Note (P-15).
const ResourceAlertGroup = "alert_group"
ResourceAlertGroup is the resource type of the Audit log entries of Commands.
const RetentionBatch = 5000
RetentionBatch is the most rows one delete of the Alert Group retention removes, so that each statement holds its row locks briefly (design/db/schema.md §6).
const TimersChannel = "muster_timers"
TimersChannel is the LISTEN/NOTIFY channel that wakes the timer workers of every replica when a timer is set.
Variables ¶
var ( // ErrNotFound is an Alert Group that does not exist in the Organization. ErrNotFound = errors.New("no such alert group") // ErrRouteNotFound is a Route that does not exist in the Organization or is deleted. ErrRouteNotFound = errors.New("no such route") // ErrDefaultRoute is a move of the Default route's own Alert Groups. ErrDefaultRoute = errors.New("the default route has no alert groups to move") )
var System = Actor{Kind: audit.ActorSystem, Transport: audit.TransportSystem}
System is Muster as the actor of a system transition.
var Table = []Row{ {EventCreated, VariantAny, KindStatus, Loud, []Mention{MentionNewAlertGroup}}, {EventAlertsAdded, VariantFiring, KindAlerts, Loud, []Mention{MentionNewAlerts}}, {EventAlertsAdded, VariantAcknowledged, KindAlerts, Quiet, nil}, {EventAlertsAdded, VariantSnoozed, KindAlerts, Quiet, nil}, {EventAlertReplaced, VariantAny, KindAlerts, Quiet, nil}, {EventAlertResolved, VariantAny, KindAlerts, Quiet, nil}, {EventAlertContinued, VariantAny, KindAlerts, Quiet, nil}, {EventAnnotationsChanged, VariantAny, KindAlerts, Quiet, nil}, {EventSeverityRaised, VariantAny, KindAlerts, Quiet, nil}, {EventUrgencyRaised, VariantRemoves, KindStatus, Loud, []Mention{MentionOwner, MentionRiseToUrgent}}, {EventUrgencyRaised, VariantRemovesNone, KindStatus, Quiet, nil}, {EventReopened, VariantFiring, KindStatus, Loud, []Mention{MentionReopen}}, {EventReopened, VariantAcknowledged, KindStatus, Loud, []Mention{MentionOwner}}, {EventReopened, VariantSnoozed, KindStatus, Quiet, nil}, {EventSnoozeEnded, VariantAny, KindStatus, Loud, []Mention{MentionSnoozeEnded}}, {EventResolved, VariantAny, KindStatus, Quiet, nil}, {EventMovedToDefaultRoute, VariantAny, KindSystem, Quiet, nil}, {EventUnacknowledged, VariantOwnerReleased, KindStatus, Loud, nil}, {EventAcknowledged, VariantAny, KindStatus, Quiet, nil}, {EventTakeover, VariantAny, KindStatus, Loud, []Mention{MentionPreviousOwner}}, {EventUnacknowledged, VariantCommand, KindStatus, Quiet, nil}, {EventUnresolved, VariantAny, KindStatus, Quiet, nil}, {EventSnoozed, VariantAny, KindStatus, Quiet, nil}, {EventUnsnoozed, VariantAny, KindStatus, Quiet, nil}, {EventNoteAdded, VariantAny, KindNotes, Quiet, nil}, {EventAckTimeout, VariantAny, KindTimers, Loud, []Mention{MentionAckTimeout}}, {EventUnclaimed, VariantAny, KindTimers, Quiet, nil}, {EventReminder, VariantAny, KindTimers, Loud, []Mention{MentionOwner}}, {EventReminderAnswered, VariantAny, KindTimers, Quiet, nil}, {EventAutoUnacknowledged, VariantAny, KindStatus, Loud, []Mention{MentionOwner}}, {EventNoticesMissed, VariantAny, KindTimers, Loud, nil}, }
Table is the lifecycle event table of C-09.FR-22 with the rows of C-10.FR-15 and C-17.FR-11, a closed list: every transition and change of an Alert Group records exactly one entry of one of its rows. The CHECKs of timeline_entries back the kinds and Mentions. notices_missed has no Mentions of its own: its entry carries those of the notices it stands for (ack_timeout or owner).
Functions ¶
func ParseWeekStart ¶
ParseWeekStart reads organization.week_start, monday to sunday.
func Range ¶
Range is the time range of a read at now: [from, to), where to defaults to the end of now — the database's microsecond after it, so that an Alert Group that started at this very time is in — and from to ListRange before to. A range that does not start before it ends is a FieldError.
func RecordSystemEntry ¶
func RecordSystemEntry(ctx context.Context, db DBTX, e SystemEntry) error
RecordSystemEntry writes the system entry e to the Timeline through db, the transaction of the caller, with Muster as the actor: the Timeline has one writer, this package, and delivery records what it learns while delivering through here (ADR-0016). Only template_value_missing and fallback_template_used — a Route template of a Thread reply, the ack timeout notice, that failed when delivery rendered it (C-12.FR-6) — are recorded this way.
func RetentionTask ¶
func RetentionTask(q Queries) func(ctx context.Context, orgID int64, now time.Time) (int64, int64, error)
RetentionTask is Purge over q in the form of the Leader task alert_group_retention: what it deleted of each kind.
func SnoozePresetEnd ¶
func SnoozePresetEnd(p SnoozePreset, now time.Time, loc *time.Location, start WorkdayStart, weekStart time.Weekday) (time.Time, error)
SnoozePresetEnd is the end of the Snooze preset p at now in the time zone loc (C-10.FR-17): from the date of now in loc, the first start of the working day strictly after now — on any day for tomorrow, on a day that is weekStart for week_start. The end is in UTC.
func StatusReasonCode ¶
StatusReasonCode is the code of the reason of an automatic status change, as the API gives it beside the reason (reason_code): the reason itself where it is one already — why an Alert resolved, why an Owner was released — and ReasonCodeNoAnswer for ReasonNoAnswer; "" for any other reason.
Types ¶
type Actor ¶
type Actor struct {
Kind audit.ActorKind
Transport audit.Transport
Person audit.Actor
Address netip.Addr
}
Actor is who changes an Alert Group and through which Transport. System transitions are made by Muster itself with the Transport system; a Command by a User or a Service account, named in Person with the token it used, from the client Address.
type ActorRef ¶
type ActorRef struct {
Kind string
PublicID string
Name string
Login string
Deactivated bool
// contains filtered or unexported fields
}
ActorRef is a User or a Service account as the API shows it; Deactivated when it was deleted.
type AlertFilter ¶
type AlertFilter struct {
State string
After *AlertPosition
Limit int
}
AlertFilter selects a page of the Alerts of an Alert Group: firing or resolved when State is set, after the position After when it is set.
type AlertPage ¶
type AlertPage struct {
Alerts []GroupAlert
Next *AlertPosition
}
AlertPage is a page of the Alerts of an Alert Group; Next is nil on the last page.
type AlertPosition ¶
AlertPosition is the place of an Alert in the list of an Alert Group: firing ones (rank 0) before the others.
type BulkItem ¶
type BulkItem struct {
PublicID string
Number *int64
Outcome BulkOutcome
Code string
Message string
}
BulkItem is the result of a bulk command for one Alert Group: its #N when it exists, the outcome and, for refused, skipped and failed, a code and a message.
type BulkOutcome ¶
type BulkOutcome string
BulkOutcome is the outcome of a bulk command for one Alert Group (BulkOutcome).
const ( BulkDone BulkOutcome = "done" BulkUnchanged BulkOutcome = "unchanged" BulkRefused BulkOutcome = "refused" BulkSkipped BulkOutcome = "skipped" BulkFailed BulkOutcome = "failed" )
The outcomes of a bulk command per Alert Group.
type BulkRequest ¶
BulkRequest is a bulk command (C-10.FR-14): Acknowledge, Resolve, Snooze or Unsnooze on the Alert Groups IDs, with the end of a Snooze, or the Note of a Resolve.
type Caller ¶
type Caller struct {
Actor audit.Actor
Transport audit.Transport
Permissions []auth.Permission
Address netip.Addr
}
Caller is who runs a Command and how: a User — through the web session, or a Personal access token, which acts as its User — or a Service account through its token; Permissions are those of the request, a Personal access token's narrowed ones (C-04.FR-7), Transport is how it reached Muster and Address the client address.
type Command ¶
type Command string
Command is a Command on an Alert Group (C-10.FR-1, CommandName).
const ( CommandAcknowledge Command = "acknowledge" CommandUnacknowledge Command = "unacknowledge" CommandResolve Command = "resolve" CommandUnresolve Command = "unresolve" CommandSnooze Command = "snooze" CommandUnsnooze Command = "unsnooze" CommandStillOnIt Command = "still_on_it" CommandAddNote Command = "add_note" )
The Commands of C-10.FR-1.
func (Command) Permission ¶
func (c Command) Permission() auth.Permission
Permission is the Permission the Command needs.
type Config ¶
type Config struct {
OrgID int64
Store Store
Audit *audit.Writer
// Business is the business clock, which dates every change, window and deadline.
Business clock.Clock
Log *logging.Logger
Restamp Restamp
}
Config is what a Service needs.
type Counts ¶
Counts are the Alert Groups matching the filters per status tab (AlertGroupCounts); All is their sum, the Open tab the sum of the firing, acknowledged and snoozed ones.
type DBTX ¶
DBTX is the connection or transaction the lifecycle runs on: the Snapshot's, a timer's or the Leader's.
type DeliveryView ¶
DeliveryView is a delivery event as the Timeline shows it.
type DurationStats ¶
DurationStats are a count of durations with their median and 95th percentile in seconds, nil when Count is 0.
type Event ¶
type Event string
Event is a lifecycle event (C-09.FR-22, C-10.FR-15, C-17.FR-11): the name a Timeline entry carries.
const ( EventCreated Event = "created" EventAlertsAdded Event = "alerts_added" EventAlertReplaced Event = "alert_replaced" EventAlertResolved Event = "alert_resolved" EventAlertContinued Event = "alert_continued" EventAnnotationsChanged Event = "annotations_changed" EventSeverityRaised Event = "severity_raised" EventUrgencyRaised Event = "urgency_raised" EventReopened Event = "reopened" EventSnoozeEnded Event = "snooze_ended" EventResolved Event = "resolved" EventMovedToDefaultRoute Event = "moved_to_default_route" EventUnacknowledged Event = "unacknowledged" )
The lifecycle events of C-09.FR-22.
const ( EventAcknowledged Event = "acknowledged" EventTakeover Event = "takeover" EventUnresolved Event = "unresolved" EventSnoozed Event = "snoozed" EventUnsnoozed Event = "unsnoozed" EventNoteAdded Event = "note_added" )
The lifecycle events of the Commands (C-10.FR-15); note_added is recorded by its Note in notes, not in timeline_entries.
const ( EventAckTimeout Event = "ack_timeout" EventUnclaimed Event = "unclaimed" EventReminder Event = "reminder" EventReminderAnswered Event = "reminder_answered" EventAutoUnacknowledged Event = "auto_unacknowledged" EventNoticesMissed Event = "notices_missed" )
The lifecycle events of the timers (C-17.FR-11). notices_missed stands for overdue ack timeout notices or Reminders collapsed into one, and carries the Mentions of the notices it stands for.
type FieldError ¶
FieldError is a query parameter of a read that is valid but cannot be used: an unknown id, a range that ends before it starts, an unknown time zone; the API answers it as 422 at Pointer.
func (*FieldError) Error ¶
func (e *FieldError) Error() string
type Filter ¶
type Filter struct {
// Statuses are the statuses to list; none means open (firing, acknowledged and snoozed), or every status for a
// number. The counts ignore them.
Statuses []Status
// Routes and Integrations are public_ids; an Alert Group matches one of each kind given.
Routes []string
Integrations []string
Severities []organization.SeverityLevel
Urgent *bool
// ResolvedBy is ResolvedByUser or ResolvedBySystem, ResolveReason the reason of a system resolve.
ResolvedBy *string
ResolveReason *string
// Reopened selects a Reopen count above zero when true, of zero when false.
Reopened *bool
// Matchers are matched against the common labels: a label the Alerts do not share counts as absent.
Matchers []matchers.Matcher
// From and To are the time range; the default is the last ListRange. A number ignores it.
From, To *time.Time
// Number is the #N to find; a Query of the form #N is the same.
Number *int64
// Query is searched in the title and summary, case-insensitively and inside words.
Query string
// Owner is a User's public_id, OwnerMe for the User Me, or OwnerNone for the Alert Groups nobody owns
// (C-10.FR-13); empty does not filter. Me is the caller, whose own Alert Groups OwnerMe selects.
Owner string
Me audit.Actor
// SnoozedNoEnd selects the Alert Groups snoozed with no end when true, and the others when false.
SnoozedNoEnd *bool
// DeliveryProblem selects the Alert Groups with a Delivery problem when true, and the others when false.
DeliveryProblem *bool
// Unclaimed selects the Unclaimed Alert Groups when true, and the others when false (C-17.FR-3).
Unclaimed *bool
}
Filter is the filters of the Alert Group list and its counts (C-09.FR-13). The zero Filter selects the open Alert Groups whose lifetime overlaps the last ListRange.
type ForbiddenError ¶
type ForbiddenError struct {
Permission auth.Permission
}
ForbiddenError is a Command the caller lacks the Permission of (403 forbidden); it changed nothing.
func (*ForbiddenError) Error ¶
func (e *ForbiddenError) Error() string
type Group ¶
type Group struct {
ID int64
PublicID string
Number int64
RouteID int64
// MovedFromRouteID is the deleted Route of an Alert Group moved to the Default route.
MovedFromRouteID *int64
KeyLabels []string
KeyValues map[string]string
KeySHA []byte
Title string
TitleFromKey bool
Summary *string
CommonLabels map[string]string
CommonAnnots map[string]string
IntegrationIDs []int64
Status Status
Severity organization.SeverityLevel
Urgent bool
OwnerUserID *int64
AcknowledgedAt *time.Time
FirstAcknowledgedAt *time.Time
SnoozeUntil *time.Time
SnoozeNoEnd bool
SnoozedWhileUrgent bool
SnoozedByUserID *int64
SnoozedByServiceAccount *int64
FiringCount, ResolvedCount, ReopenCount int64
ResolvedAt *time.Time
ResolvedByKind *string
ResolvedByUserID *int64
ResolvedByServiceAccount *int64
ResolveReason *string
ResolveReasonText *string
ReopenDeadline *time.Time
Prior *Prior
GraceDeadline *time.Time
FiringAgainAfterID *int64
EventSeq int64
CreatedAt time.Time
LastChangedAt time.Time
// FirstPublishedAt is the first Publication, where the ack timeout starts (C-17.FR-1); AckTimeoutStartedAt and
// AckTimeoutNoticesSent the ack timeout that runs and its notices sent; Unclaimed is set after its last notice.
FirstPublishedAt *time.Time
AckTimeoutStartedAt *time.Time
AckTimeoutNoticesSent int64
Unclaimed bool
// RemindersSent, RemindersUnanswered and LastReminderAt are the Reminders of the acknowledgement, and
// OwnerAnsweredAt when its Owner last answered one (C-17.FR-4, FR-5).
RemindersSent int64
RemindersUnanswered int64
LastReminderAt *time.Time
OwnerAnsweredAt *time.Time
}
Group is the working state of one alert_groups row while a transaction holds its lock.
type GroupAlert ¶
type GroupAlert struct {
Fingerprint string
Integration Ref
Labels map[string]string
Annotations map[string]string
Firing bool
Reason *string
ReasonText *string
StartsAt time.Time
ResolvedAt *time.Time
LastSeenAt time.Time
GroupKeys []string
SourceURL *string
}
GroupAlert is an Alert inside an Alert Group (AlertGroupAlert); an Alert that left a person-resolved Alert Group for another one shows as resolved there, without a reason.
type Linker ¶
Linker computes the links of the Alert Group id on read (C-12.FR-9): its Link rules, runbook_url, dashboard_url and generatorURL; (*links.Service).ForGroup is the one of the runtime.
type ListPage ¶
type ListPage struct {
Groups []View
Next *ListPosition
}
ListPage is a page of the list; Next is nil on the last page.
type ListPosition ¶
ListPosition is the place of an Alert Group in the list: the time it is sorted by and its id.
type ListRequest ¶
type ListRequest struct {
Filter
Sort Sort
After *ListPosition
Limit int
LabelColumns []string
}
ListRequest is a page of the list: the filters, the order, the position after which the page starts, its size and the labels whose shared value each item carries.
type Loudness ¶
type Loudness string
Loudness says whether an event asks for attention (Loud) or only updates what is shown (Quiet).
type Mention ¶
type Mention string
Mention is a symbolic Mention that each Destination turns into real Mentions from C-12 on.
const ( MentionOwner Mention = "owner" MentionPreviousOwner Mention = "previous_owner" MentionNewAlertGroup Mention = "new_alert_group" MentionNewAlerts Mention = "new_alerts" MentionReopen Mention = "reopen" MentionAckTimeout Mention = "ack_timeout" MentionSnoozeEnded Mention = "snooze_ended" MentionRiseToUrgent Mention = "rise_to_urgent" )
The symbolic Mentions: the Owner before the transition, the previous Owner of a Takeover, or the name of a Destination setting of C-12.FR-8.
type NextNotice ¶
NextNotice is the next scheduled ack timeout notice or Reminder of an Alert Group: the kind of its timer and when it is due.
type NotePage ¶
type NotePage struct {
Notes []NoteView
Next *NotePosition
}
NotePage is a page of Notes; Next is nil on the last page.
type NotePosition ¶
NotePosition is the place of a Note in the Notes of an Alert Group: the time it was added and its id.
type NoteView ¶
type NoteView struct {
PublicID string
Body string
Author *ActorRef
Transport string
CreatedAt time.Time
}
NoteView is a Note as its Timeline entry shows it.
type Notice ¶
type Notice struct {
Kind string
Count *int64
Label *string
ResolvedNumber *int64
RetentionDays *int64
// Related is the newer open Alert Group of newer_alert_group_exists.
Related *GroupRef
}
Notice is a banner of the Alert Group page.
type Outcome ¶
type Outcome string
Outcome is what a Command did: done, or unchanged for an idempotent repeat such as Acknowledge by the current Owner.
type PresetEnd ¶
type PresetEnd struct {
Preset SnoozePreset
Until time.Time
}
PresetEnd is the end a Snooze with the Snooze preset would set now.
type PresetList ¶
PresetList is what the Snooze presets end at now (SnoozePresetList): the time zone used, organization.workday_start and organization.week_start, and one end per Snooze preset, in the order of SnoozePresets.
type Prior ¶
type Prior struct {
Status Status
OwnerUserID *int64
SnoozeUntil *time.Time
SnoozeNoEnd bool
SnoozedWhileUrgent bool
SnoozedByUserID *int64
SnoozedByServiceAccount *int64
}
Prior is the status an Alert Group returns to when it reopens within its Reopen window (C-09.FR-4).
type Purged ¶
Purged is what one run of the retention deleted: Details, the Alerts inside Alert Groups, and Summaries, the summary rows.
func Purge ¶
Purge runs the Alert Group retention of the Organization orgID at now (C-09.FR-16): first the Alerts inside Alert Groups that ended retention.alert_details ago, then the summary rows resolved retention.alert_group_summaries ago with their Notes, timers, deliveries and queue rows by cascade, each in batches of at most RetentionBatch until a batch comes back short. Timeline and delivery event months are dropped by partition maintenance; the reads hide the details of an Alert Group from the end of retention.alert_details, whether or not they are deleted yet. Running it twice deletes nothing more, because each delete only takes rows that already qualify.
type Queries ¶
type Queries interface {
GetGroupingSettings(ctx context.Context, orgID int64) (dbgen.GetGroupingSettingsRow, error)
ListChangedAlerts(ctx context.Context, arg dbgen.ListChangedAlertsParams) ([]dbgen.ListChangedAlertsRow, error)
ListFiringMemberships(ctx context.Context, arg dbgen.ListFiringMembershipsParams) (
[]dbgen.ListFiringMembershipsRow, error)
LockRoutes(ctx context.Context, arg dbgen.LockRoutesParams) ([]dbgen.LockRoutesRow, error)
LockDefaultRoute(ctx context.Context, orgID int64) (dbgen.LockDefaultRouteRow, error)
GetRoutePolicy(ctx context.Context, arg dbgen.GetRoutePolicyParams) (dbgen.GetRoutePolicyRow, error)
FindOpenGroup(ctx context.Context, arg dbgen.FindOpenGroupParams) (int64, error)
FindReopenableGroup(ctx context.Context, arg dbgen.FindReopenableGroupParams) (int64, error)
PeekGroup(ctx context.Context, arg dbgen.PeekGroupParams) (dbgen.PeekGroupRow, error)
LockGroups(ctx context.Context, arg dbgen.LockGroupsParams) ([]dbgen.LockGroupsRow, error)
EnsureCounter(ctx context.Context, orgID int64) error
LockCounter(ctx context.Context, orgID int64) (int64, error)
SavepointGrouping(ctx context.Context) error
RollbackGrouping(ctx context.Context) error
NextNumber(ctx context.Context, orgID int64) (int64, error)
InsertGroup(ctx context.Context, arg dbgen.InsertGroupParams) (int64, error)
SaveGroup(ctx context.Context, arg dbgen.SaveGroupParams) error
IsActiveUser(ctx context.Context, arg dbgen.IsActiveUserParams) (bool, error)
LockActiveUser(ctx context.Context, arg dbgen.LockActiveUserParams) ([]int64, error)
GetUserTimeZone(ctx context.Context, arg dbgen.GetUserTimeZoneParams) (string, error)
InsertMemberships(ctx context.Context, arg dbgen.InsertMembershipsParams) error
ResolveMemberships(ctx context.Context, arg dbgen.ResolveMembershipsParams) error
MoveMemberships(ctx context.Context, arg dbgen.MoveMembershipsParams) error
UpdateMemberships(ctx context.Context, arg dbgen.UpdateMembershipsParams) error
ListGroupFiringAlerts(ctx context.Context, arg dbgen.ListGroupFiringAlertsParams) (
[]dbgen.ListGroupFiringAlertsRow, error)
InsertTimelineEntry(ctx context.Context, arg dbgen.InsertTimelineEntryParams) error
InsertNote(ctx context.Context, arg dbgen.InsertNoteParams) error
ListJoinedDuringSnooze(ctx context.Context, arg dbgen.ListJoinedDuringSnoozeParams) ([]string, error)
ListOwnedGroups(ctx context.Context, arg dbgen.ListOwnedGroupsParams) ([]int64, error)
ListOpenGroupIDs(ctx context.Context, orgID int64) ([]int64, error)
InsertDowntimeEntries(ctx context.Context, arg dbgen.InsertDowntimeEntriesParams) error
GetTimerPolicy(ctx context.Context, arg dbgen.GetTimerPolicyParams) (dbgen.GetTimerPolicyRow, error)
GetGroupTimer(ctx context.Context, arg dbgen.GetGroupTimerParams) (time.Time, error)
GetLastReminderSeq(ctx context.Context, arg dbgen.GetLastReminderSeqParams) (int64, error)
UpsertTimer(ctx context.Context, arg dbgen.UpsertTimerParams) error
DeleteTimer(ctx context.Context, arg dbgen.DeleteTimerParams) error
NotifyTimers(ctx context.Context, channel string) error
LockRouteForMove(ctx context.Context, arg dbgen.LockRouteForMoveParams) (dbgen.LockRouteForMoveRow, error)
GetDefaultRouteID(ctx context.Context, orgID int64) (int64, error)
ListOpenGroupsOfRoute(ctx context.Context, arg dbgen.ListOpenGroupsOfRouteParams) ([]int64, error)
GetGroupRef(ctx context.Context, arg dbgen.GetGroupRefParams) (dbgen.GetGroupRefRow, error)
GetSnapshotReceivedAt(ctx context.Context, arg dbgen.GetSnapshotReceivedAtParams) (time.Time, error)
// Notify sends a live-update hint once the transaction commits.
Notify(ctx context.Context, h db.Hint) error
// DB is the connection or transaction the queries run on, which the re-render step writes through.
DB() DBTX
audit.Store
// contains filtered or unexported methods
}
Queries are the queries of the package, with the insert of the Audit log.
type Recorded ¶
type Recorded struct {
Seq int64
Event Event
Variant Variant
Loudness Loudness
Mentions []Mention
Fingerprints []string
Reason string
}
Recorded is one lifecycle event that a change recorded: its row of the table with its loudness and Mentions, its number in the Alert Group, the fingerprints it names and its reason.
type RefusedError ¶
type RefusedError struct {
Code string
Message string
// Related is the newer open Alert Group of newer_alert_group_exists.
Related *GroupRef
}
RefusedError is a Command whose precondition does not hold or whose caller cannot take part (409 command-refused); it changed nothing.
func (*RefusedError) Detail ¶
func (e *RefusedError) Detail() string
Detail is the refusal as the detail of a problem.
func (*RefusedError) Error ¶
func (e *RefusedError) Error() string
type Related ¶
type Related struct {
PublicID string
Number int64
Status Status
StartedAt time.Time
// Duration runs to the resolution; nil while it is open.
Duration *time.Duration
Resolution *Resolution
}
Related is an Alert Group of the same Route and Group key values as another one (RelatedAlertGroup).
type RelatedPage ¶
type RelatedPage struct {
Groups []Related
Next *ListPosition
}
RelatedPage is a page of related Alert Groups; Next is nil on the last page.
type ReminderCheck ¶
ReminderCheck reports whether the Reminder recorded as the lifecycle event seq of the Alert Group groupID reached at least one Destination, read through db: a Thread reply of it sent, or its reminder event delivered to an events-mode outgoing webhook. delivery.ReminderReached is the one of the runtime, injected because delivery imports this package.
type Rendering ¶
type Rendering struct {
Group *Group
Actor Actor
Events []Recorded
ReceivedAt *time.Time
After func(f func(ctx context.Context))
Fallback func(f TemplateFailure)
}
Rendering is what the re-render step of the dispatcher hands to delivery (C-11.FR-1, FR-20), inside the dispatcher's transaction: the Alert Group as the change left it, who made the change, the lifecycle events it recorded in their order, and ReceivedAt, the receipt time of the Stored Snapshot behind it, nil when a Command, a timer or a person's change made it. After queues a function, such as a log line, to run once the transaction committed, never when it rolls back; Fallback reports a Route template that failed, which the dispatcher records in the Timeline once the re-render step returned. Both are nil outside the dispatcher.
type Requester ¶
Requester is who asks for a change through the API and how: the actor and the Transport of the Audit log entry, and the client address.
type Rerender ¶
Rerender is the re-render step of the dispatcher: delivery's Enqueue, which writes through tx, the dispatcher's transaction.
type Resolution ¶
Resolution is who resolved an Alert Group: a person, or the system with the reason of its last Alert.
type Restamp ¶
Restamp records, through routing, that Alerts were grouped on another Route than the one routing stamped: the Default route, when their Route was deleted while the Snapshot waited for it.
type Row ¶
Row is one row of the lifecycle event table: its event and variant, its Timeline kind, loudness and Mentions.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Alert Group lifecycle of an Organization: the grouping Sink of Snapshot processing, the system transitions of timers, downtime and Route deletion, the Commands, and the reads of Alert Groups.
func (*Service) Acknowledge ¶
Acknowledge is the Command Acknowledge of the Alert Group publicID (C-10.FR-1, FR-4): the caller becomes its Owner; by another user while acknowledged it is a Takeover, by the current Owner it changes nothing.
func (*Service) AddNote ¶
AddNote is the Command Add Note of the Alert Group publicID by the caller (C-10.FR-8): through the dispatcher, with the Permission alert-groups:note, 1 to NoteMaxLength characters, in any status. It returns the Note with its author, a User or a Service account, and its Transport.
func (*Service) AlertChanges ¶
func (s *Service) AlertChanges(ctx context.Context, tx ingestdb.DBTX, changes []ingest.AlertChange) (ingest.Routed, error)
AlertChanges is the grouping Sink (C-09.FR-3): in the Snapshot's transaction tx, after routing, the newly firing Alerts join the open Alert Group of their Route and Group key, reopen a system-resolved one inside its Reopen window or start a new one; Continuations, annotation changes and resolutions apply to the Alert Group each Alert fires in. Every firing, routed Alert belongs to an Alert Group: a listed Alert that fires in none — it fired before grouping existed, or a failure or a configuration change left it out — is grouped as if it had just fired. It returns the #N of the Alert Groups it created or changed, and what to count and log once the Snapshot committed.
The counter row is taken only when an Alert Group must be created or reopened (schema.md): Alerts that join open Alert Groups lock those alone, so that the Snapshots of an Integration's lanes do not wait for each other on the Organization's one row. Such a join that finds, after its locks, that it needs the counter row after all rolls back to a savepoint and groups again with the counter row first, as a creation does, so that no lookup after an Alert Group lock ever waits for it.
func (*Service) Alerts ¶
Alerts lists the Alerts of the Alert Group publicID (C-09.FR-14, C-06.FR-19): firing first, then resolved with their reason, each with its Integration, labels, the annotations as last seen in it, the Alertmanager groups that listed it and its source link; none once its details are removed (C-09.FR-16).
func (*Service) AnswerReminder ¶
AnswerReminder is "Still on it" (C-17.FR-10, C-10.FR-16): the Owner answers the Reminder that waits, which the answer rule of auto-unacknowledge counts; the Reminder schedule does not move.
func (*Service) Bulk ¶
Bulk runs a bulk command (C-10.FR-14): the caller needs the Permission of the command, checked once before the arguments and any Alert Group; the end of a Snooze preset is computed once, so every Alert Group gets the same end (C-10.FR-18); then each Alert Group, in the order of the request, goes through the dispatcher in a transaction of its own, with its own Audit log and Timeline entries, and a refusal of one never stops the others. A bulk Acknowledge skips an Alert Group another user owns, so it never makes a Takeover; an id that names no Alert Group fails with not found.
func (*Service) Counts ¶
Counts counts the Alert Groups matching f per status (C-09.FR-13): the filters of the list, its status aside. With label Matchers that Go applies, the database counts per status and common labels, and Go adds up the matching ones.
func (*Service) EndGracePeriod ¶
func (s *Service) EndGracePeriod(ctx context.Context, tx dbgen.DBTX, groupID int64) (ingest.Routed, error)
EndGracePeriod is the timer grace_period_end of an Alert Group a person resolved (C-09.FR-5): the Alerts still firing in it are grouped again on its Route as if they had just fired, and leave it for the Alert Group that takes them; one they start is marked as firing again after the manual resolve. It runs in the timer's transaction tx; a Grace period that moved or ended already changes nothing. A Continuation is never a new firing, so only the memberships still firing move.
func (*Service) EndReopenWindow ¶
EndReopenWindow is the timer reopen_window_end of an Alert Group (C-09.FR-12), through the dispatcher in the timer's transaction tx; a window that moved or ended already changes nothing.
func (*Service) EndSnooze ¶
func (s *Service) EndSnooze(ctx context.Context, tx dbgen.DBTX, groupID int64) (func(context.Context), error)
EndSnooze is the timer snooze_end of an Alert Group (C-09.FR-8, FR-12), through the dispatcher as a system transition in the timer's transaction tx; a Snooze that ended or moved meanwhile changes nothing, so the timer is safe to fire twice. It returns what to run once that transaction committed.
func (*Service) ExportGauges ¶
ExportGauges sets muster_alert_groups to the open Alert Groups per Route and status, as a Leader task: a series for every status of every Route that is not deleted, and of any Route that still has open ones; the series of a Route that has neither are removed. Running it twice sets the same values.
func (*Service) FireAckTimeout ¶
func (s *Service) FireAckTimeout(ctx context.Context, tx dbgen.DBTX, groupID int64) (func(context.Context), error)
FireAckTimeout is the timer ack_timeout of an Alert Group (C-17.FR-2, FR-3, FR-7), through the dispatcher as a system transition in the timer's transaction tx. An Alert Group that is no longer firing, whose ack timeout ended or whose Route turned it off changes nothing, and the timer is then removed without a notice; the notices due are counted on the locked row, so the timer is safe to fire twice. It returns what to run once that transaction committed.
func (*Service) FireReminder ¶
func (s *Service) FireReminder(ctx context.Context, tx dbgen.DBTX, groupID int64, deadline time.Time) ( func(context.Context), error)
FireReminder is the timer reminder of an Alert Group, claimed with its deadline (C-17.FR-4, FR-5, FR-7), through the dispatcher as a system transition in the timer's transaction tx. One that comes due on an Alert Group that is no longer acknowledged, or whose Route turned the Reminders off, changes nothing and logs reminder_skipped, and the timer is then removed. It returns what to run once that transaction committed.
func (*Service) Get ¶
Get reads the Alert Group publicID (C-09.FR-1, FR-10, FR-14): its status, Route, Integrations, title and summary, Severity level, urgency as its Route and organization.critical_is_urgent give it now, counts, the resolution, its Owner and Snooze, its labels, its links and the notices of its page — newer_alert_group_exists for a person-resolved one whose key another open Alert Group took (C-10.FR-7); once its details are removed, the notice details_removed with the period (C-09.FR-16).
func (*Service) List ¶
List reads a page of the Alert Group list (C-09.FR-13): the summary rows that match the filters, in the order of the request, after its position. Label Matchers other than = with a value are matched in Go on the common labels, batch after batch, until the page is full; a page that has read maxScan rows returns what it found and the position to go on from. Each item carries its Route, Integrations, resolution, urgency, details_removed and label_values.
func (*Service) MarkPublished ¶
MarkPublished records the first Publication of the Alert Group groupID at at, the published_at of that delivery or the delivered_at of its created event (C-17.FR-1, D277, D298): a system transition of the dispatcher in a transaction of its own, which delivery calls after the transaction that recorded the Publication committed, as that one locks deliveries before alert_groups and the dispatcher the other way round. It changes nothing for an Alert Group published before, so that a republication after the Root message was deleted never starts the ack timeout over and a repeated call is safe.
func (*Service) MoveOpenAlertGroups ¶
func (s *Service) MoveOpenAlertGroups(ctx context.Context, r Requester, publicID string) (int, error)
MoveOpenAlertGroups moves the open Alert Groups of the Route publicID to the Default route (C-09.FR-19), each with a moved_to_default_route entry, and records one Audit log entry with their count, which it returns. The Route is locked against grouping meanwhile, so no Alert Group of it opens while they move. An unknown or deleted Route is ErrRouteNotFound, the Default route ErrDefaultRoute.
func (*Service) Notes ¶
func (s *Service) Notes(ctx context.Context, publicID string, after *NotePosition, limit int) (NotePage, error)
Notes lists the Notes of the Alert Group publicID in the order they were added, after the position when given (C-10.FR-8), each with its author and Transport. Notes are kept with the summary row, so they are listed also once the details were removed (C-09.FR-16).
func (*Service) OpenCounts ¶
OpenCounts counts, for each Integration of the public_ids, the open Alert Groups with an Alert from it (C-09.FR-21): those that deleting it would resolve. An Integration without any is left out.
func (*Service) RecordDowntime ¶
RecordDowntime gives every open Alert Group the system entry "Muster was unavailable from … to …" (C-09.FR-18, C-02.FR-12), in the transaction tx in which the Leader records the downtime, so that a downtime is recorded once with its entries. The entry is no lifecycle event: it reaches neither delivery nor outgoing webhook events.
func (*Service) Related ¶
func (s *Service) Related(ctx context.Context, publicID string, after *ListPosition, limit int) (RelatedPage, error)
Related lists the other Alert Groups of the Route of the Alert Group publicID with the same Group key values, newest first, after the position when given (C-09.FR-20): number, status, start, duration and who resolved them.
func (*Service) ReleaseOwner ¶
func (s *Service) ReleaseOwner(ctx context.Context, tx usersdb.DBTX, userID int64, reason string) ( func(context.Context), error)
ReleaseOwner releases the acknowledgements of the User userID, whom an Admin disabled (ReasonOwnerDisabled) or deleted (ReasonOwnerDeleted), in the transaction tx of that change (C-03.FR-13): each Alert Group they own goes through the dispatcher as a system transition — actor and Transport system, no Permission and no Audit log entry of its own, since the user's own entry records the cause. It locks as grouping does: the counter row, then the Alert Groups in id order. It returns what to run once tx committed.
func (*Service) Resolve ¶
func (s *Service) Resolve(ctx context.Context, c Caller, publicID string, note *string) (Result, error)
Resolve is the Command Resolve: resolved by the caller, with the Grace period of the Alerts still firing (C-09.FR-5). A Note in the same request, which needs alert-groups:note too, records note_added after resolved in the same transaction (C-10.FR-15).
func (*Service) SetReminderReached ¶
func (s *Service) SetReminderReached(f ReminderCheck)
SetReminderReached fills the answer rule's check of the Reminders; without it no Reminder counts as reached, so none is unanswered and auto-unacknowledge never happens.
func (*Service) SetRerender ¶
SetRerender fills the re-render step of the dispatcher, before anything changes an Alert Group.
func (*Service) Snooze ¶
func (s *Service) Snooze(ctx context.Context, c Caller, publicID string, end SnoozeEnd) (Result, error)
Snooze is the Command Snooze until end, which names exactly one of a future until, no_end and a Snooze preset (C-10.FR-6, FR-18); a preset's end is computed before the Alert Group is locked (resolveEnd).
func (*Service) SnoozePresets ¶
SnoozePresets are the ends a Snooze with each Snooze preset would set now for the caller c (C-10.FR-18), in the time zone timeZone, or, when it is empty, the one C-10.FR-17 picks for the caller. It needs alert-groups:snooze, reads nothing else and changes nothing; a time zone Muster does not know is invalid_format at /query/time_zone.
func (*Service) Statistics ¶
func (s *Service) Statistics(ctx context.Context, r StatisticsRequest) (Statistics, error)
Statistics aggregates the summary rows that started in the period per Route or per Integration (C-09.FR-15): the number of Alert Groups, time to resolve of the resolved ones and time to acknowledge of those acknowledged at least once, as count, median and 95th percentile, in total and per day of start in the time zone. An Alert Group with Alerts from several Integrations counts for each. The items are every Route or Integration that is not deleted and the deleted ones with Alert Groups in the period, or only the chosen ones, by name.
func (*Service) Timeline ¶
func (s *Service) Timeline(ctx context.Context, publicID string, f TimelineFilter) (TimelinePage, error)
Timeline reads the Timeline of the Alert Group publicID (C-09.FR-11, FR-14): its entries with the Notes and the delivery events merged by time, newest first unless Ascending, filtered by kind, each with its actor and Transport and, for a lifecycle event, its event, loudness and Mentions. Once its details are removed only the Notes remain (C-09.FR-16).
func (*Service) Unacknowledge ¶
Unacknowledge is the Command Unacknowledge: firing without an Owner.
type SnoozeEnd ¶
type SnoozeEnd struct {
Until *time.Time
NoEnd bool
Preset SnoozePreset
TimeZone *string
// contains filtered or unexported fields
}
SnoozeEnd is the end of a Snooze, chosen explicitly: a future Until, NoEnd, or a Snooze preset whose end the Command computes (C-10.FR-6, FR-17, FR-18). TimeZone is the time zone of the preset when the request names one; without it the Command takes the caller's (readPresetBasis).
type SnoozePreset ¶
type SnoozePreset string
SnoozePreset is a Snooze preset: a Snooze that ends at the next start of the working day, or at the start of the working day on the first day of the week (C-10.FR-17).
const ( PresetTomorrow SnoozePreset = "tomorrow" PresetWeekStart SnoozePreset = "week_start" )
The Snooze presets of C-10.FR-17.
func PresetOrder ¶
func PresetOrder() []SnoozePreset
PresetOrder is the Snooze presets in the order the API, the UI and messengers offer them.
type Sort ¶
type Sort string
Sort is the order of the list: by start or by last change, a leading - for newest first.
type Statistics ¶
type Statistics struct {
GroupBy string
From, To time.Time
Items []StatisticsItem
}
Statistics are the statistics of a period (AlertGroupStatistics).
type StatisticsDay ¶
type StatisticsDay struct {
Date time.Time
AlertGroupCount int64
TimeToAcknowledge DurationStats
TimeToResolve DurationStats
}
StatisticsDay is one day of start in the time zone, with its Alert Groups.
type StatisticsItem ¶
type StatisticsItem struct {
Subject Ref
AlertGroupCount int64
TimeToAcknowledge DurationStats
TimeToResolve DurationStats
PerDay []StatisticsDay
}
StatisticsItem is the statistics of one Route or Integration: totals and the days with Alert Groups.
type StatisticsRequest ¶
type StatisticsRequest struct {
GroupBy string
Routes []string
Integrations []string
From, To *time.Time
TimeZone string
}
StatisticsRequest asks for the statistics per Route or per Integration: GroupBy is ByRoute or ByIntegration, Routes or Integrations (public_ids, the kind of GroupBy only) narrow the subjects, From and To are the period of start (the last ListRange by default) and TimeZone the IANA zone that splits the days (organization.time_zone by default).
type Store ¶
type Store interface {
Queries
InTx(ctx context.Context, f func(Queries) error) error
// CustomPlans are the queries over a connection that plans each statement with its parameters, for the list,
// whose optional filters a generic plan of a prepared statement could not use the indexes of.
CustomPlans() Queries
}
Store runs the queries alone or in one transaction.
type SystemEntry ¶
type SystemEntry struct {
OrgID int64
AlertGroupID int64
At time.Time
System SystemEvent
Detail string
}
SystemEntry is a system entry another package records about an Alert Group of the Organization OrgID: what happened, when, and its detail.
type SystemEvent ¶
type SystemEvent string
SystemEvent is the system_event of a system entry.
const ( SystemMovedToDefaultRoute SystemEvent = "moved_to_default_route" SystemFallbackTemplateUsed SystemEvent = "fallback_template_used" )
The system entries this capability writes, and fallback_template_used, which the dispatcher records when the re-render step reports a Route template that failed (C-12.FR-6).
const SystemTemplateValueMissing SystemEvent = "template_value_missing"
SystemTemplateValueMissing is the system entry of a value an extraction rule of an outgoing webhook did not find in the response of its "create" or "open thread" (C-15.FR-4); delivery records it.
type TemplateFailure ¶
TemplateFailure is a Route template that failed while the re-render step rendered a message of the Alert Group, which then used the Fallback template (C-12.FR-6): its kind and what failed.
type TimelineActor ¶
type TimelineActor struct {
Kind string
Ref *ActorRef
TokenName *string
Transport string
Reason *string
}
TimelineActor is who caused an entry and how.
type TimelineEntry ¶
type TimelineEntry struct {
PublicID string
At time.Time
Kind Kind
Event string
Loudness Loudness
Mentions []string
System string
Actor TimelineActor
Reason *string
ReasonCode string
From, To Status
Owner *ActorRef
PreviousOwner *ActorRef
SnoozeUntil *time.Time
Fingerprints []string
ReplacedLabel *string
LabelConflicts []string
NoticeNumber *int64
MissedCount *int64
PeriodFrom *time.Time
PeriodTo *time.Time
Detail *string
Note *NoteView
Delivery *DeliveryView
// contains filtered or unexported fields
}
TimelineEntry is one entry of the Timeline (TimelineEntry): a lifecycle event or a system entry, a Note or a delivery event. Event is empty for a system entry without a lifecycle event; ReasonCode is StatusReasonCode of Reason.
type TimelineFilter ¶
type TimelineFilter struct {
Kinds []Kind
Ascending bool
After *TimelinePosition
Limit int
}
TimelineFilter selects a page of a Timeline: only the Kinds when set, oldest first when Ascending, after the position After when it is set.
type TimelinePage ¶
type TimelinePage struct {
Entries []TimelineEntry
Next *TimelinePosition
}
TimelinePage is a page of a Timeline; Next is nil on the last page.
type TimelinePosition ¶
TimelinePosition is the place of an entry in the Timeline: its time, its source and its id there.
type Variant ¶
type Variant string
Variant tells apart the rows of one event: the status an Alert Group had or returns to, or whether a rise to Urgent removed an acknowledgement or a Snooze.
const ( VariantAny Variant = "" VariantFiring Variant = "firing" VariantAcknowledged Variant = "acknowledged" VariantSnoozed Variant = "snoozed" VariantRemoves Variant = "removes" VariantRemovesNone Variant = "removes_none" VariantCommand Variant = "command" VariantOwnerReleased Variant = "owner_released" )
The variants of the rows of C-09.FR-22 and C-10.FR-15; VariantAny is an event with a single row. unacknowledged has two: by the Command Unacknowledge, and when its Owner is disabled or deleted.
type View ¶
type View struct {
PublicID string
Number int64
Title string
Summary *string
Status Status
Severity organization.SeverityLevel
Urgent bool
Route Ref
Integrations []Ref
StartedAt time.Time
LastChangedAt time.Time
ResolvedAt *time.Time
ReopenCount int64
FiringCount int64
ResolvedCount int64
Resolution *Resolution
GroupLabels map[string]string
CommonLabels map[string]string
CommonAnnotations map[string]string
Notices []Notice
// DetailsRemoved is set once retention.alert_details passed since the resolution: the Alerts and the Timeline
// are gone, the summary and the Notes stay (C-09.FR-16).
DetailsRemoved bool
// LabelValues are the values of the labels the list asked for that the Alerts share.
LabelValues map[string]string
// Owner is the Owner while acknowledged; SnoozeUntil, nil for no end, and SnoozedBy the Snooze while snoozed.
Owner *ActorRef
SnoozeUntil *time.Time
SnoozedBy *ActorRef
// Newer is, for an Alert Group a person resolved, the open Alert Group of its Route and key that takes part in
// grouping (C-10.FR-7).
Newer *GroupRef
// Links are its links, computed on read (C-09.FR-14, C-12.FR-9).
Links []Link
// DeliveryProblem is set while a delivery of it is Not delivered or deleted in the messenger, waits for a Broken
// Destination, or has a Thread not attached (C-13.FR-12).
DeliveryProblem bool
// Unclaimed is set after the last notice of its ack timeout until it stops being firing (C-17.FR-3), and
// NextNotice is its next ack timeout notice or Reminder, nil when none is scheduled (C-17.FR-9).
Unclaimed bool
NextNotice *NextNotice
// contains filtered or unexported fields
}
View is an Alert Group as getAlertGroup reads it.
func (View) Allowed ¶
Allowed is allowed_commands of the Alert Group for the caller (C-10.FR-16): the Commands its status allows for the caller's Permissions and identity, in the order of CommandName. Acknowledge of an Alert Group another user owns is a Takeover, and is not offered to the Owner, for whom it would change nothing; a Service account is never offered Acknowledge. Unresolve is offered only while every precondition holds: a person resolved the Alert Group, its Route was not deleted, no newer open Alert Group of its Route and key takes part in grouping, and one of its Alerts still fires — the API still refuses it when that changes before the command arrives. still_on_it is offered only to the Owner, never to a Service account, while a Reminder waits for an answer (C-17.FR-10); add_note in every status to a caller with alert-groups:note.
type WorkdayStart ¶
type WorkdayStart struct {
Hour, Minute int
}
WorkdayStart is the start of the working day, organization.workday_start, as a wall-clock time.
func ParseWorkdayStart ¶
func ParseWorkdayStart(s string) (WorkdayStart, error)
ParseWorkdayStart reads organization.workday_start, HH:MM on the 24-hour clock.