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, alert_group_teams, alert_group_assignees, 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 ActorStatistics
- type ActorStatisticsItem
- type AlertFilter
- type AlertPage
- type AlertPosition
- type Assignee
- type BulkItem
- type BulkOutcome
- type BulkRequest
- type CallOutcome
- type Caller
- type ChainEntry
- type ChainProgress
- type ChainRef
- type ChainRuns
- type ChainStart
- type ChainStop
- type Command
- type Config
- type Counts
- type DBTX
- type DeliveryView
- type DurationStats
- type Event
- type FieldError
- type Filter
- type FinalEdits
- type ForbiddenError
- type Group
- type GroupAlert
- type GroupRef
- type GroupTeam
- type Growth
- type JoinedDestination
- type Kind
- type Link
- type Linker
- type ListPage
- type ListPosition
- type ListRequest
- type Loudness
- type Mention
- type MentionName
- type MentionPage
- type MentionTarget
- type MentionView
- type NextNotice
- type NotePage
- type NotePosition
- type NoteView
- type Notice
- type Outcome
- type Page
- type PageGateway
- type PageOutcome
- type PageRequest
- type PageSource
- type PageTarget
- type PageTargets
- type PageTeam
- type PagedUser
- 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) ActorStatistics(ctx context.Context, f Filter) (ActorStatistics, 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) ChainStep(ctx context.Context, tx DBTX, groupID int64, ...) (func(context.Context), 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, startsChains bool) 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) SetChainRuns(r ChainRuns)
- func (s *Service) SetFinalEdits(f FinalEdits)
- func (s *Service) SetLinks(l Linker)
- func (s *Service) SetPageTargets(t PageTargets)
- func (s *Service) SetReminderReached(f ReminderCheck)
- func (s *Service) SetRerender(r Rerender)
- func (s *Service) SettleCall(ctx context.Context, tx DBTX, o CallOutcome) (func(context.Context), error)
- func (s *Service) SettlePage(ctx context.Context, tx DBTX, groupID int64, o PageOutcome) (func(context.Context), error)
- 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 StepCall
- type StepPage
- type StepSkip
- type StepWebhook
- type Store
- type SystemEntry
- type SystemEvent
- type TeamMembership
- type TeamRef
- type TemplateFailure
- type TimelineActor
- type TimelineDestination
- type TimelineEntry
- type TimelineFilter
- type TimelinePage
- type TimelinePosition
- type UpdateWorker
- 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 ( SkipOutsideWorkingHours = "outside_working_hours" SkipSeverity = "severity" SkipScheduleGap = "schedule_gap" SkipViewer = "viewer" SkipDisabled = "disabled" SkipDestinationDeleted = "destination_deleted" SkipWebhookEventsRequired = "webhook_events_required" //nolint:gosec // G101: a skip reason, not a credential SkipNoMentionPossible = "no_mention_possible" SkipGatewayDeleted = "gateway_deleted" SkipNoConfirmedContact = "no_confirmed_contact" )
The reasons of escalation_step_skipped (EscalationSkipReason). A webhook step whose Destination was deleted, or is no longer an outgoing webhook in the mode events or both, is skipped with SkipDestinationDeleted or SkipWebhookEventsRequired; a page_team step that none of its chain's Destinations can carry, such as one whose only Destination is a Telegram channel, with SkipNoMentionPossible (C-32.FR-9). A call step or a call action of a rule whose Notification gateway was deleted, or is no Notification gateway any more, is skipped with SkipGatewayDeleted, and for a person without a confirmed contact there with SkipNoConfirmedContact (C-32.FR-14, C-30.FR-9, C-31.FR-3).
const ( StopAcknowledge = "acknowledge" StopSnooze = "snooze" StopResolve = "resolve" StopStartedOver = "started_over" )
The Commands that stop the runs of the chains of an Alert Group (stop_command), and started_over for a run that a start-over found still running.
const ( ReasonMinimumSeverity = "Minimum severity of the Route" ReasonCodeMinimumSeverity = "minimum_severity" )
ReasonMinimumSeverity is the reason of a severity_raised, or of the Quiet urgency_raised that removes nothing, that the Minimum severity of the Route made rather than an Alert (C-26.FR-9); ReasonCodeMinimumSeverity is its code.
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 ( PageCallRefused = "call_refused" PageCallUnknown = "call_unknown" PageCallBudgetUsed = "call_budget_used" PageNoConfirmedContact = "no_confirmed_contact" PageGatewayDeleted = "gateway_deleted" PageGatewayBroken = "gateway_broken" PageNoRootMessage = "no_root_message" PageNoAccountLink = "no_account_link" PageRepliesFailed = "not_delivered" )
The reasons of page_not_delivered for a call through a Notification gateway (C-30.FR-7, PageNotDeliveredReason): the gateway refused it, answered what Muster cannot classify, kept failing until delivery.transient_budget was used, or the person had no confirmed contact at the gateway at its first attempt, or the gateway was deleted, or is no Notification gateway any more, before the call was sent (C-30.FR-9), or it came due while the gateway was Broken (C-30.FR-8). A Page by Mention is not delivered when none of its chain's Destinations has the Alert Group's Root message, when the person has no Account link in the Identity space of any of them, or when every Thread reply that could mention them ended Not delivered, was withheld while its Destination was Broken or was sent with its line of Mentions leaving them out for length (C-32.FR-10, C-12.FR-11).
const ( PageSourceRoute = "route" PageSourceTeam = "team" )
The sources of the run of a chain, which decide where it Pages (C-32.FR-8): its Route, and the Teams that named it.
const ( PagePending = "pending" PageDelivered = "delivered" PageNotDelivered = "not_delivered" PageKindMention = "mention" PageKindCall = "call" )
The outcomes of a Page and of a person it names, and the kinds of a Page: by Mention, and by a call through a Notification gateway.
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" ByTeam = "team" )
The subjects of the statistics (group_by).
const ( TeamRuleLabel = "label" TeamRuleMatcher = "matcher" )
The rules by which an Alert belongs to a Team (C-25.FR-5), as routing records them.
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 ( KindRouteMinimumSeverity = "route_minimum_severity" KindRouteMessageLabels = "route_message_labels" KindDestinationButtons = "destination_buttons" KindOrganizationButtons = "organization_buttons" KindTeamEvaluation = "team_evaluation" KindOrganizationMessageSettings = "organization_message_settings" KindTeamName = "team_name" KindTeamDestinations = "team_destinations" KindRouteMessageSettings = "route_message_settings" KindOrganizationLinks = "organization_links" KindUserName = "user_name" KindAccountLinks = "account_links" KindServiceAccountName = "service_account_name" KindDestinationConnection = "destination_connection" OpenGroupUpdatesChannel = "muster_open_group_updates" )
The kinds of open_group_updates rows: a changed Minimum severity or "Labels in the message" of a Route (C-29.FR-2), which routing writes, a changed button set of a Destination or of the Organization (C-28.FR-9), which destinations and organization write, the evaluation of the Teams of the open Alert Groups after a save of a Team or of the Team label (C-25.FR-13), which teams and organization write, and a changed Severity label, Team label, Instance labels, time zone, start of the working day or first day of the week of the Organization, or a renamed Team, whose values the Root messages show (C-29.FR-1 to FR-3), which organization and teams write, and the changed Destination entries of a Team, its deletion included (C-26.FR-6, C-25.FR-10), which teams writes; a changed language, Snooze durations or root_message or line template of a Route, which its Root messages show (C-12.FR-2, FR-3, C-10.FR-6), which routing writes, and a created, changed or deleted Link rule or Lookup table, from which the links of every Root message are computed (C-12.FR-9), which links writes; a changed display name or Account links of a User, and a renamed Service account, whom the footer of a Root message names (C-12.FR-12), which users, accountlinks and tokens write; the changed Connection of a Destination, whose identity space decides the footer of its Root messages (C-12.FR-12), which destinations writes; and OpenGroupUpdatesChannel, the LISTEN/NOTIFY channel that wakes the workers of every replica when a row is inserted.
const ( UpdateLease = time.Minute UpdateBatch = 50 UpdateMaxWait = 30 * time.Second )
The defaults of the worker: the lease of a claimed row, renewed with each batch, the open Alert Groups one batch takes, the longest wait between rounds, which bounds what a missed notification costs, the shortest one, and the first wait after a failed round.
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 TeamMine = "mine"
TeamMine is the value of Filter.Team that selects the Alert Groups of the Teams of the caller ("My Teams").
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 PageReasons = []string{PageCallRefused, PageCallUnknown, PageCallBudgetUsed, PageNoConfirmedContact, PageGatewayDeleted, PageGatewayBroken, PageNoRootMessage, PageNoAccountLink, PageRepliesFailed}
PageReasons are the reasons of page_not_delivered, a closed list.
var ReachEvents = []Event{EventTeamJoined, EventSeverityRaised, EventUrgencyRaised}
ReachEvents are the lifecycle events by which the Destinations an Alert Group reaches can grow (C-26.FR-4, FR-5): a Team that joins it, which adds the Team's Destinations, and a rise of its Severity level, which adds the Destinations whose condition it now meets. The dispatcher records destination_joined only after one of them that Alerts made, and delivery creates the deliveries of newly reached Destinations only after one of them, so that both read the same notion of a growing reach; Alerts that join without a Team or a rise add no Destination.
var SkipReasons = []string{SkipOutsideWorkingHours, SkipSeverity, SkipScheduleGap, SkipViewer, SkipDisabled, SkipDestinationDeleted, SkipWebhookEventsRequired, SkipNoMentionPossible, SkipGatewayDeleted, SkipNoConfirmedContact}
SkipReasons are the reasons of escalation_step_skipped, a closed list.
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}, {EventTeamJoined, 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}, {EventUnknownTeamValue, VariantAny, KindSystem, Quiet, nil}, {EventDestinationJoined, VariantFiring, KindSystem, Loud, []Mention{MentionNewAlertGroup}}, {EventDestinationJoined, VariantAcknowledged, KindSystem, Quiet, nil}, {EventDestinationJoined, VariantSnoozed, 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}, {EventPaged, VariantAny, KindEscalation, Loud, []Mention{MentionPaged}}, {EventPaged, VariantCall, KindEscalation, Quiet, nil}, {EventPageNotDelivered, VariantAny, KindEscalation, Quiet, nil}, {EventEscalationStepSkipped, VariantAny, KindEscalation, Quiet, nil}, {EventEscalationWebhook, VariantAny, KindEscalation, Quiet, nil}, {EventAssigneesChanged, VariantAny, KindEscalation, Quiet, nil}, }
Table is the lifecycle event table of C-09.FR-22 with the rows of C-10.FR-15, C-17.FR-11, C-25, C-26, C-30 and C-32, 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, ReasonCodeMinimumSeverity for ReasonMinimumSeverity; "" for any other reason.
Types ¶
type Actor ¶
type Actor struct {
Kind audit.ActorKind
Transport audit.Transport
Person audit.Actor
Address netip.Addr
// Gateway is the Connection of the Notification gateway of the call a Command through the Transport gateway came
// from, written to gateway_connection_id of its status entry; 0 for none.
Gateway int64
}
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 ActorStatistics ¶
type ActorStatistics struct {
From, To time.Time
Items []ActorStatisticsItem
}
ActorStatistics are the statistics by people of a period (AlertGroupActorStatistics).
type ActorStatisticsItem ¶
type ActorStatisticsItem struct {
Actor *ActorRef
AcknowledgedFirst int64
Resolved int64
TimeToAcknowledge DurationStats
}
ActorStatisticsItem is one row of the statistics by people: a User or a Service account, or the Alert Groups whose first acknowledgement names nobody when Actor is nil. TimeToAcknowledge is over the Alert Groups it acknowledged first, whose number is AcknowledgedFirst.
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 Assignee ¶
Assignee is a person a chain of an Alert Group Paged last and reached (Assignee): the User, the owning Team of the chain when its run started, nil for none, the chain, nil once it was deleted, and since when.
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 CallOutcome ¶
type CallOutcome struct {
Call int64
Accepted bool
Reason string
Groups []int64
User PagedUser
Gateway PageGateway
FirstAttempt time.Time
}
CallOutcome is how a call through a Notification gateway ended, which the gateway sender reports in the transaction of its end (C-30.FR-4, FR-7, C-32.FR-12): the call by internal id; Accepted when the gateway accepted it; else the reason it ended Not delivered, or none when it was dropped, as every Alert Group of it stopped; the Alert Groups it was about, without those dropped before its first attempt; the person and the gateway; and when the call made its first attempt, zero for one dropped before it.
type Caller ¶
type Caller struct {
Actor audit.Actor
Transport audit.Transport
Permissions []auth.Permission
Address netip.Addr
// Gateway is the Connection of the Notification gateway of the call that a Command through the Transport gateway
// came from, which its Timeline entries name (C-30.FR-6); 0 for any other Transport.
Gateway int64
}
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 ChainEntry ¶
ChainEntry names the run, the chain and the step of an escalation entry by internal ids, with the chain's public_id and name for the outgoing webhook events; Chain is 0 and ChainPublicID empty once the chain was deleted.
type ChainProgress ¶
type ChainProgress struct {
Skips []StepSkip
Webhooks []StepWebhook
Pages []StepPage
RanOut bool
Changed bool
}
ChainProgress is what one step of a run, or one action of a Notification rule, did to its Alert Group: the skips, the webhooks and the Pages by Mention to record, whether the run ran out, and whether anything of the run changed, which the Alert Group's read shows.
type ChainRef ¶
ChainRef is an Escalation chain as a Timeline entry names it, with its owning Team, nil when none.
type ChainRuns ¶
type ChainRuns interface {
// Start starts the chains that apply to g, in its current start g.ChainGeneration, as s says, and returns how
// many runs it started; a chain that already runs in that start takes the new sources that name it (P-70).
Start(ctx context.Context, tx DBTX, g *Group, s ChainStart) (int, error)
// Stop stops every run of g that still runs, with what stopped it; a run that ran out stays as it is.
Stop(ctx context.Context, tx DBTX, g *Group, s ChainStop) error
// Started reports whether chains started in the current start of g, running, run out or stopped.
Started(ctx context.Context, tx DBTX, g *Group) (bool, error)
// RanOut reports whether every run of the current start of g ran out, at least one and none stopped (C-32.FR-7).
RanOut(ctx context.Context, tx DBTX, g *Group) (bool, error)
}
ChainRuns are the runs of the Escalation chains of Alert Groups (C-32.FR-4 to FR-7), which the dispatcher starts and stops in its transaction tx, after the Alert Group's lock: escalation implements it and internal/runtime wires it, since groups imports no package of Paging (ADR-0016).
type ChainStart ¶
type ChainStart struct {
All bool
Rise bool
Before organization.SeverityLevel
Teams []int64
At time.Time
// After queues a function, such as a log line, to run once the transaction committed; nil runs it at once.
After func(f func(ctx context.Context))
}
ChainStart says which chains a point of C-32.FR-5 starts: every chain that applies, at a start or a start-over; or, while the chains run, only those whose condition a rise of the Severity level from Before newly meets (Rise) and those the Teams that joined name (Teams).
type ChainStop ¶
type ChainStop struct {
Command string
EventSeq int64
At time.Time
// After queues a function to run once the transaction committed; nil runs it at once.
After func(f func(ctx context.Context))
}
ChainStop is what stopped the runs of an Alert Group: the Command (StopAcknowledge, StopSnooze, StopResolve or StopStartedOver), the lifecycle event of the change that stopped them, 0 for none, and when.
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 ¶
type DeliveryView struct {
Event string
Destination Ref
Error *string
Mention *MentionView
}
DeliveryView is a delivery event as the Timeline shows it, with the undelivered Mention of a mention_not_delivered.
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.
The lifecycle events of the Teams of an Alert Group (C-25.FR-6, FR-7, revised C-09.FR-22): a Team that joins its Teams, and a value of the Team label that names no Team, once per value.
const EventAssigneesChanged Event = "assignees_changed"
EventAssigneesChanged is the lifecycle event of C-32.FR-12 (revised C-09.FR-22): the Assignees of an Alert Group changed — a Page reached someone, or Acknowledge, Snooze or Resolve cleared them — Quiet, without Mentions, of the Timeline kind escalation, an update of the Root messages. Its entry keeps the Assignees after the change in assignees (assignees.go).
const EventDestinationJoined Event = "destination_joined"
EventDestinationJoined is the lifecycle event of C-26.FR-5 (revised C-09.FR-22): an Alert Group that reaches a Destination after its first Publication elsewhere, because its Alerts raised its Severity level into the Destination's condition or brought a Team, publishes there — Loud with the Mentions of a new Alert Group while it is firing, Quiet while it is acknowledged or snoozed. One is recorded per Destination it joins.
const EventEscalationStepSkipped Event = "escalation_step_skipped"
EventEscalationStepSkipped is the lifecycle event of C-32.FR-14 (revised C-09.FR-22): a step of an Escalation chain that was skipped — outside the Working hours of its chain, for a Severity level its condition does not meet, in a gap of the Schedule it Pages, or for a person it names who became a Viewer or was disabled since it was saved — Quiet, without Mentions, of the Timeline kind escalation, nothing in a messenger. Its entry names the run, the chain, the step and the reason, and the person for a skip of a person.
const EventEscalationWebhook Event = "escalation_webhook"
EventEscalationWebhook is the lifecycle event of C-32.FR-13 (revised C-09.FR-22): a step "Send to an outgoing webhook" that was made — Quiet, without Mentions, of the Timeline kind escalation, nothing in a messenger, and, unlike every other event, sent only to the outgoing webhook Destination the step names (C-15.FR-2 revised). Its entry names the run, the chain, the step and that Destination.
const EventPageNotDelivered Event = "page_not_delivered"
EventPageNotDelivered is the lifecycle event of C-30.FR-7 and C-32.FR-10 (revised C-09.FR-22): a Page that reached its person nowhere, here a call through a Notification gateway that ended Not delivered — Quiet, without Mentions, of the Timeline kind escalation, nothing in a messenger. Its entry names the people in paged_user_ids, the gateway and the reason. escalation_step_skipped and escalation_webhook are in escalation.go.
const EventPaged Event = "paged"
EventPaged is the lifecycle event of C-32.FR-9 and FR-19 (revised C-09.FR-22): an Escalation step, or an action of a Notification rule, Pages people, a Team or everyone in the chat by Mention — Loud with the Mention paged, of the Timeline kind escalation, a Thread reply in the Threads of its chain's Destinations (C-32.FR-8). Its entry names the people in paged_user_ids, or the Team of a page_team step in team_id and its token in page_everyone, and the importance of a Page of people in page_importance. A Page by a call through a Notification gateway (VariantCall, C-30.FR-4) is Quiet, without Mentions, nothing in a messenger: the gateway calls; its entry names the person and the gateway in gateway_connection_id.
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
// Team is a Team's public_id, or TeamMine for the Teams of the User Me: the Alert Groups that have it among their
// Teams (C-09.FR-13, C-25.FR-2); empty does not filter.
Team string
// FirstAcknowledgedBy is a User's public_id, or OwnerMe for the User Me: the Alert Groups whose first
// acknowledgement that User made (C-09.FR-27, FR-30); empty does not filter. Only the statistics read it.
FirstAcknowledgedBy string
// Assignee is a User's public_id, or OwnerMe for the User Me: the Alert Groups where that User is an Assignee
// (C-32.FR-18), which are open, as only a firing Alert Group has Assignees; empty does not filter.
Assignee string
}
Filter is the filters of the Alert Group list and its counts (C-09.FR-13), and of the statistics (C-09.FR-30), which one resolution shares. The zero Filter selects the open Alert Groups whose lifetime overlaps the last ListRange; the statistics select the Alert Groups that started in it instead.
type FinalEdits ¶
type FinalEdits interface {
FinalEditsFor(ctx context.Context, tx DBTX, g *Group, team int64) (int, error)
}
FinalEdits gives the final edit of C-11.FR-14 (C-26.FR-6, C-25.FR-10), in the transaction tx that re-rendered the open Alert Group g after a change of the Destination entries of its Team team, to each delivery of g whose entries hold an entry of the Team that no entry still names: neither an entry of its Route nor, while the Route delivers to the Teams, an entry of one of its Teams, met or not. It returns how many deliveries it changed. Delivery implements it; groups declares it, since it cannot import delivery.
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
Description *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
// FirstAcknowledgedBy is the User of the first acknowledgement, set with FirstAcknowledgedAt (C-09.FR-27); nil
// when a replica of an earlier version made it, or before the Timeline it was filled from was kept.
FirstAcknowledgedBy *int64
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
// ChainGeneration is the current start of its Escalation chains, raised by each start and start-over, 0 before the
// first (C-32.FR-5).
ChainGeneration int64
// contains filtered or unexported fields
}
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
// Teams are the Teams it belongs to, decided when it last started firing (C-25.FR-5).
Teams []TeamMembership
}
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 GroupTeam ¶
type GroupTeam struct {
TeamMembership
JoinedAt time.Time
}
GroupTeam is a Team of an Alert Group (C-25.FR-6): the rule of the first Alert that brought it and when it joined.
type Growth ¶
type Growth struct {
Team, Destination int64
}
Growth is what a change of a Team's Destination entries may add to the reach of the open Alert Groups that have the Team (C-26.FR-6): the Team's entry of the Destination it added or changed, by internal ids.
type JoinedDestination ¶
type JoinedDestination struct {
ID int64
PublicID string
Name string
Type string
Entries []routing.Reaching
}
JoinedDestination is the Destination of a destination_joined: its internal id, public_id, name and type, and the entries of the reach that reached it, which delivery records on the delivery it creates.
type Kind ¶
type Kind string
Kind is the Timeline kind of an entry.
const ( KindStatus Kind = "status" KindAlerts Kind = "alerts" KindTimers Kind = "timers" KindSystem Kind = "system" KindNotes Kind = "notes" KindDelivery Kind = "delivery" // KindEscalation is the kind of the events of Escalation chains and Pages (C-32.FR-19), from L2. KindEscalation Kind = "escalation" )
The Timeline kinds stored in timeline_entries; Notes and delivery events are merged in from their own tables.
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" // MentionPaged is the Mention of paged: the people of the Page by their Account links, or the Team mention or the // token of a page_team step, in the Destinations of the chain (C-32.FR-9). MentionPaged Mention = "paged" )
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 MentionName ¶
MentionName is a group — a group entry or a Team mention — or everyone in the chat as a Mention names it: its kind, group or everyone, and its name, the group's name or the word.
type MentionPage ¶
MentionPage is the Page whose Thread reply left out the Team mention or everyone in the chat that it named: the number of its step and the name of its chain when the chain's run started.
type MentionTarget ¶
type MentionTarget struct {
Kind string `json:"kind"`
UserID string `json:"user_id,omitempty"`
TeamID string `json:"team_id,omitempty"`
Group string `json:"group,omitempty"`
GroupID string `json:"group_id,omitempty"`
Everyone string `json:"everyone,omitempty"`
User *ActorRef `json:"-"`
Team *TeamRef `json:"-"`
}
MentionTarget is the target of a Mention entry — a person, the On-call of a Team or of the Teams from the label, a Team, the Teams from the label, a group or everyone — with its User or Team by public_id, its group or its word, and the User or the Team it names.
type MentionView ¶
type MentionView struct {
User *ActorRef
Mention *MentionName
Position int
Target *MentionTarget
Event string
Reason string
Page *MentionPage
}
MentionView is an undelivered Mention as the Timeline shows it (C-28.FR-3): the person — or, through a bridge whose Mention line left it out for length (C-12.FR-11), the group or everyone in the chat, with no person — the entry that named them — its position and target then, no target for a template's token — the Loud event, empty for a token, and the reason. The Team mention or everyone of a Page has no entry and no event but its Page (C-32.FR-9).
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 Page ¶
type Page struct {
Users []PagedUser
Gateway *PageGateway
Reason string
ID int64
Targets []PageTarget
Team *PageTeam
Everyone string
Importance string
}
Page is a Page as the Timeline entry of an event of the kind escalation names it (C-32.FR-19): the people it names, the Notification gateway of a call, nil for a Page by Mention, and the reason a Page was not delivered. groups knows no package of Paging (S-169); the callers fill it. A paged by Mention also carries its pages row, the Destinations its Thread replies go to, which delivery fans the event out into (C-32.FR-8), and the Team or the token of a page_team step; it and the page_not_delivered of a Page by Mention carry the importance of a Page of people.
type PageGateway ¶
PageGateway is the Notification gateway of a call: its Connection by internal id, public_id and name.
type PageOutcome ¶
PageOutcome is what the Thread replies of a Page by Mention did so far, which delivery reports (C-32.FR-10): the people a delivered reply mentioned, whether every reply ended — sent, Not delivered or withheld — and whether one was delivered, which delivers a Page of a Team or of everyone in the chat.
type PageRequest ¶
type PageRequest struct {
Sources []PageSource
Team int64
Everyone string
People []int64
}
PageRequest is what a Page asks PageTargets for: the sources of its run, the Team or the token of a page_team step, and the people of a Page of people.
type PageSource ¶
PageSource is a source of the run of a chain: its Route, or a Team by id.
type PageTarget ¶
type PageTarget struct {
DestinationID int64
Source string
Linked []int64
Named []int64
Withheld bool
}
PageTarget is a Destination a Page writes a Thread reply in (C-32.FR-8, FR-9): the Destination, whether it is one of the Route or of a Team of the chain (PageSourceRoute, PageSourceTeam), the people of the Page with an Account link in its Identity space, whom its reply mentions — every person for an outgoing webhook, which takes them as data —, those with an Account link whom its reply names by the plain name, which reaches none of them, as a bridge without native_mentions does (C-32.FR-11, C-22.FR-16), and whether its reply is withheld, as while it is Broken (C-11.FR-19).
type PageTargets ¶
type PageTargets interface {
PageTargets(ctx context.Context, tx DBTX, g *Group, r PageRequest) ([]PageTarget, error)
}
PageTargets finds the Destinations of a run that can carry a Page, in the dispatcher's transaction tx after the lock of g: those of its sources that have the Alert Group's Root message, and for a page_team step only those whose Connection can mention the Team or the token. delivery implements it and internal/runtime wires it, since groups imports no package of delivery (ADR-0016).
type PagedUser ¶
PagedUser is a person a Page names: a User by internal id, public_id, name and login.
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 the steps of the runs of their Escalation chains, 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 and the steps of the runs of the chains of Alert Groups resolved then, 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) ([]string, 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)
LockRouteStorm(ctx context.Context, arg dbgen.LockRouteStormParams) ([]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)
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)
ListAlertTeams(ctx context.Context, arg dbgen.ListAlertTeamsParams) ([]dbgen.ListAlertTeamsRow, error)
AddGroupTeams(ctx context.Context, arg dbgen.AddGroupTeamsParams) ([]int64, error)
AddUnknownTeamValues(ctx context.Context, arg dbgen.AddUnknownTeamValuesParams) ([]string, error)
GetRouteDeliverToTeams(ctx context.Context, arg dbgen.GetRouteDeliverToTeamsParams) (bool, error)
ListGroupTeamIDs(ctx context.Context, arg dbgen.ListGroupTeamIDsParams) ([]int64, error)
ListGroupsTeamIDs(ctx context.Context, arg dbgen.ListGroupsTeamIDsParams) ([]dbgen.ListGroupsTeamIDsRow, error)
ListReachEntries(ctx context.Context, arg dbgen.ListReachEntriesParams) ([]dbgen.ListReachEntriesRow, error)
SetChainGeneration(ctx context.Context, arg dbgen.SetChainGenerationParams) 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
// Destination is the Destination a destination_joined joined, or the only one an escalation_webhook is sent to;
// Team is the Team a team_joined joined, 0 for none.
Destination *JoinedDestination
Team int64
// Page is the Page of an event of the kind escalation, which outgoing webhooks carry (C-15.FR-2).
Page *Page
// Chain is the run, the chain and the step of an event of an Escalation chain, which outgoing webhooks carry.
Chain *ChainEntry
}
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
// OwnerName is the name of the Owner of owned_by_other, which an Acknowledge through a Notification gateway is
// refused with; empty for an Owner without a row, whom the Transport names in its own language.
OwnerName string
// contains filtered or unexported fields
}
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)
Changed func()
Configuration bool
Grows *Growth
Teams []int64
// Unreached, when set, is called by the re-render of the creation of the Alert Group when no Destination reaches
// it, or only Broken ones, so that its chains start at once (C-32.FR-5).
Unreached func()
}
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. Changed, when set, is called for each delivery whose Desired state the re-render step changed: the re-render of a button set counts with it. Configuration marks a rendering that a change of configuration made, as the evaluation of the Teams of the open Alert Groups on a save (C-25.FR-13) and the re-render of a button set do: whatever its lifecycle events, it publishes Quietly and releases a held Urgent Alert Group Quietly (ADR-0018). Grows, when set, marks the re-render, without a lifecycle event, of a change of a Team's Destination entries that added or changed the Team's entry of one Destination (C-26.FR-6): delivery publishes the Alert Group Quietly in that Destination when that entry reaches it now and it has no delivery there, or one whose final edit was done, and nowhere else; it is a change of configuration too. Teams are the Teams of the Alert Group by id, from which, with its Severity level, the re-render step applies the reach (routing.Reach, C-26.FR-2); the Destinations the change joined are those of its destination_joined events, and a change of configuration records none (C-26.FR-5).
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) ActorStatistics ¶
ActorStatistics aggregates the Alert Groups that started in the period and match f by people (C-09.FR-28): per User the Alert Groups they acknowledged first, with time to acknowledge, and those they resolved; per Service account those it resolved; and the Alert Groups acknowledged whose first acknowledgement names nobody as an item without an Actor, last. The items go by AcknowledgedFirst, most first, then by name regardless of case, by name, and by public_id; deleted Users and Service accounts are marked Deactivated.
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) ChainStep ¶
func (s *Service) ChainStep(ctx context.Context, tx DBTX, groupID int64, step func(ctx context.Context, g *Group) (ChainProgress, error)) (func(context.Context), error)
ChainStep makes one step of a run of an Escalation chain on the Alert Group groupID in the timer's transaction tx (C-32.FR-5, FR-13, FR-14): it locks the Alert Group first, as every change of it does, runs step on it — which reads and writes the run under that lock — and records what step did through the dispatcher as system transitions with Muster as the actor: escalation_step_skipped for each skip, escalation_webhook for each step that sent to an outgoing webhook and paged and page_not_delivered for each Page by Mention, in the order of the steps (chainSteps); the timer of a Notification rule's next action goes through it too. When the run ran out, unclaimed once every run of the current start has (ChainsRanOut). An Alert Group that no longer exists changes nothing. It returns what to run once tx committed.
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 that level gives it (critical, C-26.FR-8), 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 ¶
func (s *Service) MarkPublished(ctx context.Context, groupID int64, at time.Time, startsChains bool) error
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, with whether it starts the Escalation chains, false only for a Publication that a change of configuration released (C-17.FR-1, C-32.FR-5, 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) SetChainRuns ¶
SetChainRuns fills the runs of the Escalation chains, before anything changes an Alert Group; without them no chain runs and every Alert Group keeps the ack timeout of C-17.
func (*Service) SetFinalEdits ¶
func (s *Service) SetFinalEdits(f FinalEdits)
SetFinalEdits fills the final edits of the open Alert Group updates team_destinations, before any runs.
func (*Service) SetPageTargets ¶
func (s *Service) SetPageTargets(t PageTargets)
SetPageTargets fills where Pages go, before anything changes an Alert Group; without it no step Pages by Mention.
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) SettleCall ¶
func (s *Service) SettleCall(ctx context.Context, tx DBTX, o CallOutcome) (func(context.Context), error)
SettleCall records how the call o.Call through a Notification gateway ended for the Pages that joined it and its Alert Groups, in the transaction tx of the end of the call, through the dispatcher as system transitions with Muster as the actor (PageReached and PageNotDelivered, callSettled; C-30.FR-7, C-32.FR-12): the gateway sender calls it before it ends the call in the same transaction. It locks the Alert Groups in id order first, as every change of Alert Groups does, so the caller takes them before any lock of its own; one that no longer exists is skipped. A call ended, accepted or Not delivered, counts each Page it settled in muster_pages_total with the kind call. It returns what to run once tx committed.
func (*Service) SettlePage ¶
func (s *Service) SettlePage(ctx context.Context, tx DBTX, groupID int64, o PageOutcome) (func(context.Context), error)
SettlePage records what the Thread replies of the Page o.Page of the Alert Group groupID did, in the transaction tx of delivery (PageReached, PageNotDelivered; C-32.FR-10): it locks the Alert Group, then the Page, and records through the dispatcher as a system transition with Muster as the actor. An Alert Group or a Page that no longer exists, and a Page that ended, change nothing. It returns what to run once tx committed. An outcome that reached someone, who may become an Assignee whom the footer of the firing Alert Group names (C-12.FR-12), first takes the lock of the evaluation of the Teams shared, as a Snapshot does (ShareTeamEvaluation): a batch of user_name or account_links takes it exclusively before it lists, so it waits for this outcome and then finds its Alert Group, or this outcome waits for the batch and renders the name and Account links after the change. The rows of the people are not locked: the changes of a User lock the active Admins before the User, in an order a lock of several people here could cross.
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 and match the filters per Route, per Integration or per Team (C-09.FR-15, FR-29, FR-30): 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, and one with several Teams for each Team. The items are every Route, Integration or Team that is not deleted and the deleted ones with Alert Groups in the period, or only the chosen ones — the caller's Teams for TeamMine, none when the caller is in none — 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, Integration or Team: totals and the days with Alert Groups.
type StatisticsRequest ¶
StatisticsRequest asks for the statistics per Route, per Integration or per Team: GroupBy is ByRoute, ByIntegration or ByTeam; Filter selects the Alert Groups (C-09.FR-30) — its Routes, Integrations, Severities, Urgent, Team, Reopened, Matchers and FirstAcknowledgedBy, with Me the caller, and From and To the period of start, the last ListRange by default; the list's other filters are not read. The filter of the kind of GroupBy also narrows the subjects. TimeZone is the IANA zone that splits the days (organization.time_zone by default).
type StepCall ¶
type StepCall struct {
Gateway PageGateway
Queue func(ctx context.Context, tx DBTX, page int64) (int64, func(context.Context), error)
}
StepCall is the call of a Page through a Notification gateway (C-30.FR-4): the gateway, and Queue, which queues the call of the Page, its pages row page, in the dispatcher's transaction tx once every Alert Group the change locks is locked (gateways, Lock order), and returns the internal id of the call it joined and what to run once tx committed. escalation fills it, through gateways, which groups does not import.
type StepPage ¶
type StepPage struct {
ChainEntry
Sources []PageSource
OwningTeam int64
People []int64
Team int64
Everyone string
Importance string
Schedule int64
AgainSeconds int
Again bool
RuleRun int64
After int
Seq int
RunStepSeq int
Call *StepCall
}
StepPage is one Page by Mention that a step of a run, or an action of a Notification rule, makes (C-32.FR-3, C-31.FR-3): the run, the chain and the step; the sources and the owning Team of the run, which name where it Pages and "Chain of the Team"; the people, each by the first Mention their rule makes at that moment, or the Team or the token of a page_team step; the importance of the step; the Schedule of a page_on_call step; the wait until the next Mention of the rule, 0 for none; whether it is a later Mention of a rule and that rule run. After and Seq are its place among the skips and the webhooks of the same ChainProgress, which keep the order of the steps. RunStepSeq is the seq of the run step that made the first Mentions of a step, 0 for a later Mention of a rule, whose rule run carries the seq of the step that started it: the order of the steps of a run, by which the Assignees change (C-32.FR-12). Call makes it a Page of one person by a call through a Notification gateway instead (C-32.FR-3, C-31.FR-3): a step "Call through a Notification gateway", or a call action of a rule run, RuleRun.
type StepSkip ¶
type StepSkip struct {
ChainEntry
Reason string
Person *PagedUser
}
StepSkip is one escalation_step_skipped: the run, the chain and the step, and the reason, with the person of a skip of a person (SkipViewer, SkipDisabled).
type StepWebhook ¶
type StepWebhook struct {
ChainEntry
Destination JoinedDestination
After int
Seq int
}
StepWebhook is one escalation_webhook (C-32.FR-13): the run, the chain and the step, and the outgoing webhook Destination it is sent to, which the run checked in the step's transaction. After is its place among the skips of the same ChainProgress: it was made after the first After of them, so that the events keep the order of the steps; Seq orders it among the Pages with the same After.
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" SystemUnknownTeamValue SystemEvent = "unknown_team_value" SystemDestinationJoined SystemEvent = "destination_joined" )
The system entries this capability writes, fallback_template_used, which the dispatcher records when the re-render step reports a Route template that failed (C-12.FR-6), and unknown_team_value, the system entry of the lifecycle event of the same name (C-25.FR-7), and destination_joined, the system entry of its lifecycle event (C-26.FR-5).
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 TeamMembership ¶
TeamMembership is a Team an Alert belongs to, with the rule that decided it when the Alert started firing and, for the rule matcher, the Team matcher.
type TeamRef ¶
TeamRef names a Team, deleted or not: a deleted Team keeps its name in the Alert Groups that had it (C-25.FR-10).
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 TimelineDestination ¶
type TimelineDestination struct {
PublicID string
Name string
Type string
Health string
BrokenSince *time.Time
BrokenReason *string
}
TimelineDestination is the Destination of a Timeline entry with its type and health, deleted or not.
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
// Team, TeamRule and TeamMatcher are the Team of a team_joined, the rule that brought it and its Team matcher;
// TeamValue is the value of an unknown_team_value (C-25.FR-6, FR-7).
Team *TeamRef
TeamRule *string
TeamMatcher *string
TeamValue *string
// Destination is the Destination of a destination_joined (C-26.FR-5), or the outgoing webhook Destination of an
// escalation_webhook (C-32.FR-13).
Destination *TimelineDestination
// PagedUsers are the people a Page names and Gateway the Notification gateway of a call, for an event of the kind
// escalation (C-32.FR-19, C-30.FR-7), the reason being Reason, or of the call an acknowledgement through the
// Transport gateway came from (C-30.FR-6).
PagedUsers []*ActorRef
Gateway *Ref
// Everyone is the word for everyone in the chat that a page_team step wrote, and Importance how a step Paged its
// people, normal or important, of a Page by Mention's paged and page_not_delivered (C-32.FR-19); the Team of a
// page_team step is Team.
Everyone *string
Importance *string
// Chain and Step are the Escalation chain and the number of the step of an event of a chain, such as
// escalation_step_skipped, whose reason is Reason (C-32.FR-14); Chain is nil once the chain was deleted, and
// ChainName is the name it had when the run started.
Chain *ChainRef
ChainName string
Step *int
// Assignees are the Assignees after an assignees_changed (C-32.FR-12), none once cleared; assignees are those of
// its row, which entryAssignees names.
Assignees []Assignee
// 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 UpdateWorker ¶
type UpdateWorker struct {
// Service is the Alert Group lifecycle of the Organization, set before Run.
Service *Service
// Lease names this replica in leased_by and carries the clocks: leases on the real clock.
Lease db.Lease
Log *logging.Logger
// MaxWait bounds the wait between rounds, and Batch the open Alert Groups of one batch; zero is the default.
MaxWait time.Duration
Batch int
// Wait waits for d or until a wake arrives; nil waits on the real clock.
Wait func(ctx context.Context, d time.Duration, wake <-chan struct{})
// contains filtered or unexported fields
}
UpdateWorker runs the open Alert Group updates of this replica (C-26.FR-9).
func (*UpdateWorker) Round ¶
Round claims and runs every row that is free, one at a time, and returns how long until the next one can be claimed. A row that fails is logged and runs again on any replica once its lease runs out; the round goes on.
func (*UpdateWorker) Run ¶
func (w *UpdateWorker) Run(ctx context.Context)
Run runs the updates until ctx ends: a round at once, then a wait until a row can be claimed, between the minimum and MaxWait, or until woken; after a failed round, a backoff.
func (*UpdateWorker) Wake ¶
func (w *UpdateWorker) Wake()
Wake makes the worker run a round at once: a row was inserted, the development clock moved, or the LISTEN is back.
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" VariantCall Variant = "call" )
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. paged has two: by Mention, and by a call through a Notification gateway (VariantCall).
type View ¶
type View struct {
PublicID string
Number int64
Title string
Summary *string
Status Status
Severity organization.SeverityLevel
Urgent bool
Route Ref
Integrations []Ref
// Teams are its Teams in the order they joined (C-25.FR-6).
Teams []GroupTeam
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
// Assignees are its Assignees, by chain in the order the runs started (C-32.FR-12, FR-18).
Assignees []Assignee
// 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.