Documentation
¶
Index ¶
- Constants
- type Alert
- func (a *Alert) Ack()
- func (a *Alert) ApplyLegacyFields()
- func (a *Alert) InsightsEvent(eventType types.InsightsEventType, reason, channelID string) types.InsightsEvent
- func (a *Alert) LogFields() map[string]any
- func (a *Alert) Nack()
- func (a *Alert) SetDefaultValues(settings *config.ManagerSettings)
- type Command
- type CommandAction
- type EscalationResult
- type InFlightMessage
- type InFlightMsgConstructor
- type Issue
- func (issue *Issue) AddAlert(alert *Alert, logger types.Logger) bool
- func (issue *Issue) AddAlertWithReason(alert *Alert, logger types.Logger) (bool, string)
- func (issue *Issue) ApplyEscalationRules() *EscalationResult
- func (issue *Issue) ApplyWebhookResult(cmd *Command) (bool, bool)
- func (issue *Issue) ArchivedInsightsEvent(archivedAt time.Time) types.InsightsEvent
- func (issue *Issue) ChannelID() string
- func (issue *Issue) ClearPostClickState() (bool, bool)
- func (issue *Issue) ClearSlackPostPending()
- func (issue *Issue) CurrentPostID() string
- func (issue *Issue) ExpirePostClickState(now time.Time) bool
- func (issue *Issue) FindWebhook(id string) *types.Webhook
- func (issue *Issue) FollowUpEnabled() bool
- func (issue *Issue) GetCorrelationID() string
- func (issue *Issue) GetSlackAction() SlackAction
- func (issue *Issue) HasPendingSlackPost() bool
- func (issue *Issue) HasSlackPost() bool
- func (issue *Issue) InsightsEvent(eventType types.InsightsEventType, reason string) types.InsightsEvent
- func (issue *Issue) IsFireAndForget() bool
- func (issue *Issue) IsInfoOrResolved() bool
- func (issue *Issue) IsLowerPriorityThan(other *Issue) bool
- func (issue *Issue) IsOpen() bool
- func (issue *Issue) IsReadyForArchiving() bool
- func (issue *Issue) IsResolved() bool
- func (issue *Issue) IsResolvedAsInconclusive() bool
- func (issue *Issue) IsResolvedAt(t time.Time) bool
- func (issue *Issue) IsWebhookHidden(webhookID string) bool
- func (issue *Issue) LastAlertHasActiveMentions() bool
- func (issue *Issue) LogFields() map[string]any
- func (issue *Issue) MarshalJSON() ([]byte, error)
- func (issue *Issue) MarshalJSONAndCache() ([]byte, error)
- func (issue *Issue) RegisterArchiving()
- func (issue *Issue) RegisterHideOptionButtonsRequest()
- func (issue *Issue) RegisterInvestigateRequest(user string)
- func (issue *Issue) RegisterMoveRequest(reason MoveIssueReason, user, newChannelID, newChannelName string)
- func (issue *Issue) RegisterMuteRequest(user string)
- func (issue *Issue) RegisterResolveRequest(user string)
- func (issue *Issue) RegisterShowOptionButtonsRequest()
- func (issue *Issue) RegisterSlackPostAdopted(slackPostID string)
- func (issue *Issue) RegisterSlackPostCreatedOrUpdated(slackPostID string, action SlackAction, fingerprint SlackPostFingerprint)
- func (issue *Issue) RegisterSlackPostDeleted()
- func (issue *Issue) RegisterSlackPostInvalidBlocks()
- func (issue *Issue) RegisterSlackPostPending()
- func (issue *Issue) RegisterSlackPostPendingWriteAhead(maxPostDuration time.Duration)
- func (issue *Issue) RegisterTerminationRequest(user string)
- func (issue *Issue) RegisterUninvestigateRequest()
- func (issue *Issue) RegisterUnmuteRequest()
- func (issue *Issue) RegisterUnresolveRequest()
- func (issue *Issue) RegisterWebhookClick(webhook *types.Webhook, cmd *Command) bool
- func (issue *Issue) ResetCachedJSONBody()
- func (issue *Issue) Resolution() string
- func (issue *Issue) SlackPostPendingExpired() bool
- func (issue *Issue) SlackPostPendingGraceElapsedAt(t time.Time) bool
- func (issue *Issue) UniqueID() string
- type ManagerSettingsWrapper
- type MoveIssueReason
- type MoveMapping
- type PostClickState
- type SlackAction
- type SlackPostFingerprint
- type WebhookCommandParams
- type WebhookOutcome
- type WebhookOutcomeStatus
- type WebhookResultParams
Constants ¶
const ( CommandActionTerminateIssue = CommandAction("terminate_issue") CommandActionResolveIssue = CommandAction("resolve_issue") CommandActionUnresolveIssue = CommandAction("unresolve_issue") CommandActionInvestigateIssue = CommandAction("investigate_issue") CommandActionUninvestigateIssue = CommandAction("uninvestigate_issue") CommandActionMuteIssue = CommandAction("mute_issue") CommandActionUnmuteIssue = CommandAction("unmute_issue") CommandActionMoveIssue = CommandAction("move_issue") CommandActionCreateIssue = CommandAction("create_issue") CommandActionShowIssueOptionButtons = CommandAction("show_issue_option_buttons") CommandActionHideIssueOptionButtons = CommandAction("hide_issue_option_buttons") CommandActionWebhook = CommandAction("webhook") // CommandActionWebhookResult is an internal command, sent by the manager itself when the result of a webhook // is known. It is never triggered directly by a user. CommandActionWebhookResult = CommandAction("webhook_result") )
const ( // SlackPostPendingGracePeriod is how long a pending Slack post (see [Issue.SlackPostPendingSince]) is waited for, // before it is assumed that the post was never created. This allows for the post to become visible in the // channel history. SlackPostPendingGracePeriod = 30 * time.Second // SlackPostPendingMaxAge is how long a pending Slack post is kept when the channel history cannot be read. // After this, the post is assumed to not exist, and the issue can be posted (and archived) again. SlackPostPendingMaxAge = 10 * time.Minute )
const ( // MoveIssueReasonEscalation indicates the issue was moved due to escalation rules. MoveIssueReasonEscalation = MoveIssueReason("ESCALATION") // MoveIssueReasonUserCommand indicates the issue was moved manually by a Slack user. MoveIssueReasonUserCommand = MoveIssueReason("USER_COMMAND") )
const ( ActionNone = SlackAction("NONE") ActionAlert = SlackAction("ALERT") ActionResolve = SlackAction("RESOLVE") )
const ( // WebhookOutcomeSending means the webhook has been accepted and is waiting to be delivered. WebhookOutcomeSending = WebhookOutcomeStatus("sending") // WebhookOutcomeDelivered means the webhook was delivered to the target. WebhookOutcomeDelivered = WebhookOutcomeStatus("delivered") // WebhookOutcomeFailed means the webhook could not be delivered, or was never sent. WebhookOutcomeFailed = WebhookOutcomeStatus("failed") // WebhookOutcomeRejected means the webhook was delivered, but the receiving system rejected the request, // e.g. because of invalid input. WebhookOutcomeRejected = WebhookOutcomeStatus("rejected") )
const ( WebhookReasonUserLookupFailed = "your Slack user could not be looked up" WebhookReasonQueueFailed = "the request could not be queued for processing" WebhookReasonIssueNotActive = "the issue is no longer active" WebhookReasonConfigError = "the webhook is not configured correctly, please contact an administrator" WebhookReasonTimeout = "the request timed out" WebhookReasonUnreachable = "the receiving system could not be reached" WebhookReasonDeliveryFailed = "delivery failed" )
Default user-facing failure reasons for webhooks. See WebhookOutcome.Reason.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct {
types.Alert
SlackChannelName string `json:"slackChannelName"`
OriginalSlackChannelID string `json:"originalSlackChannelId"`
OriginalText string `json:"originalText"`
// contains filtered or unexported fields
}
Alert represents an alert message to be sent to a Slack channel. It extends the types.Alert struct with additional fields needed in this package.
func (*Alert) Ack ¶
func (a *Alert) Ack()
Ack acknowledges the alert message, indicating successful processing. Any subsequent calls to Ack or Nack will have no effect.
func (*Alert) ApplyLegacyFields ¶
func (a *Alert) ApplyLegacyFields()
ApplyLegacyFields maps deprecated legacy alert fields to their current equivalents. The deprecated DeletionDelaySeconds is used as the archiving delay when ArchivingDelaySeconds is not set. Must be called before SetDefaultValues, which sets a default archiving delay.
func (*Alert) InsightsEvent ¶
func (a *Alert) InsightsEvent(eventType types.InsightsEventType, reason, channelID string) types.InsightsEvent
InsightsEvent returns an insights event of the given type and reason, describing this alert as processed in channelID. RelatedChannelID is set to the original channel if the alert was redirected by a move mapping.
func (*Alert) LogFields ¶
LogFields returns a map of key-value pairs representing the Alert's important fields for logging purposes.
func (*Alert) Nack ¶
func (a *Alert) Nack()
Nack negatively acknowledges the alert message, indicating processing failure and requesting re-delivery. Any subsequent calls to Ack or Nack will have no effect.
func (*Alert) SetDefaultValues ¶
func (a *Alert) SetDefaultValues(settings *config.ManagerSettings)
SetDefaultValues sets default values for the Alert fields based on the provided ManagerSettings.
type Command ¶
type Command struct {
Timestamp time.Time `json:"timestamp"`
SlackChannelID string `json:"slackChannelId,omitempty"`
SlackPostID string `json:"ts,omitempty"`
Reaction string `json:"reaction,omitempty"`
UserID string `json:"userId,omitempty"`
UserRealName string `json:"userRealName,omitempty"`
Action CommandAction `json:"action,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
WebhookParameters *WebhookCommandParams `json:"webhookParameters,omitempty"`
WebhookResult *WebhookResultParams `json:"webhookResult,omitempty"`
IncludeArchivedIssues bool `json:"includeArchivedIssues"`
ExecuteWhenNoIssueFound bool `json:"executeWhenNoIssueFound"`
// contains filtered or unexported fields
}
Command represents a user-initiated action within Slack that the system needs to process.
func NewCommand ¶
func NewCommand(slackChannelID, ts, reaction, userID, userRealName string, action CommandAction, parameters map[string]any) *Command
NewCommand creates a new Command instance with the provided parameters.
func NewWebhookResultCommand ¶ added in v0.19.0
func NewWebhookResultCommand(webhookCmd *Command, status WebhookOutcomeStatus) *Command
NewWebhookResultCommand creates a CommandActionWebhookResult command for the given webhook command, which reports the webhook result back to the channel manager. The user and Slack post are copied from webhookCmd.
func (*Command) Ack ¶
func (c *Command) Ack()
Ack acknowledges the command message, indicating successful processing. Any subsequent calls to Ack or Nack will have no effect.
func (*Command) DedupID ¶
DedupID generates a deduplication ID for the command based on its key attributes.
func (*Command) LogFields ¶
LogFields returns a map of key-value pairs representing the Command's important fields for logging purposes.
func (*Command) Nack ¶
func (c *Command) Nack()
Nack negatively acknowledges the command message, indicating processing failure and requesting re-delivery. Any subsequent calls to Ack or Nack will have no effect.
func (*Command) ParamAsBool ¶
ParamAsBool retrieves a boolean parameter by key from the Command's Parameters map.
func (*Command) ParamAsInt ¶
ParamAsInt retrieves an integer parameter by key from the Command's Parameters map.
func (*Command) ParamAsString ¶
ParamAsString retrieves a string parameter by key from the Command's Parameters map.
type CommandAction ¶
type CommandAction string
CommandAction represents the type of action a user has initiated within Slack.
type EscalationResult ¶
type EscalationResult struct {
Issue *Issue
Escalated bool
MoveToChannel string
// Changed is true if the escalation became active for the first time, or raised the issue severity,
// in this attempt. Escalated stays true on every attempt while a rule is active; Changed does not.
Changed bool
// PrevSeverity is the issue severity before the escalation was applied (only set when Escalated is true).
PrevSeverity types.AlertSeverity
}
EscalationResult represents the outcome of an escalation attempt for an issue.
type InFlightMessage ¶
type InFlightMessage interface {
Ack()
Nack()
}
InFlightMessage represents a message that is currently being processed. It should be acknowledged (Ack) or negatively acknowledged (Nack) once processing is complete.
Ack and Nack do not accept a context parameter because acknowledgment is a commitment that must complete regardless of the caller's context state. Each queue implementation is responsible for managing its own timeouts and retry logic internally.
func NewAlertFromQueueItem ¶
func NewAlertFromQueueItem(queueItem *types.FifoQueueItem) (InFlightMessage, error)
NewAlertFromQueueItem creates a new Alert instance from a FifoQueueItem. It unmarshals the JSON body of the queue item into an Alert struct.
func NewCommandFromQueueItem ¶
func NewCommandFromQueueItem(queueItem *types.FifoQueueItem) (InFlightMessage, error)
NewCommandFromQueueItem creates a Command instance from a FIFO queue item. It unmarshals the JSON body of the queue item into a Command struct.
type InFlightMsgConstructor ¶
type InFlightMsgConstructor func(queueItem *types.FifoQueueItem) (InFlightMessage, error)
InFlightMsgConstructor is a function type that constructs an InFlightMessage from a FifoQueueItem. The actual implementation may vary based on the message type (e.g., Alert, Command).
type Issue ¶
type Issue struct {
ID string `json:"id"`
CorrelationID string `json:"correlationId"`
Created time.Time `json:"created"`
// FirstAlert is the first alert that created this issue. This field is retained for debugging
// purposes only and is not used in any business logic.
FirstAlert *Alert `json:"firstAlert"`
// LastAlert is the most recent alert for this issue. All issue state is derived from this alert.
// This field must never be nil after issue creation or deserialization.
LastAlert *Alert `json:"lastAlert"`
AlertCount int `json:"alertCount"`
LastAlertReceived time.Time `json:"lastAlertReceived"`
LastSlackMention string `json:"lastSlackMention"`
LastSlackMentionTime time.Time `json:"lastSlackMentionTime"`
AutoResolvePeriod time.Duration `json:"autoResolvePeriod"`
ArchiveDelay time.Duration `json:"archiveDelay"`
ArchiveTime time.Time `json:"archiveTime"`
Archived bool `json:"archived"`
ResolveTime time.Time `json:"resolveTime"`
SlackPostID string `json:"slackPostId"`
SlackPostCreated time.Time `json:"slackPostCreated"`
SlackPostUpdated time.Time `json:"slackPostUpdated"`
// SlackPostContentUpdated is the time the alert content of the post (see [SlackPostFingerprint.Content]) was last
// changed, and SlackPostPrevContentUpdated the time of the change before it (zero if there is none). The gap between
// the two is used to back off content updates for issues where the content changes frequently.
SlackPostContentUpdated time.Time `json:"slackPostContentUpdated"`
SlackPostPrevContentUpdated time.Time `json:"slackPostPrevContentUpdated"`
// SlackPostFingerprint identifies the content of the current Slack post, used to classify the next update
// (see [SlackPostFingerprint]).
SlackPostFingerprint SlackPostFingerprint `json:"slackPostFingerprint"`
SlackPostLastAction SlackAction `json:"slackPostLastAction"`
SlackPostNeedsUpdate bool `json:"slackPostNeedsUpdate"`
SlackPostNeedsDelete bool `json:"slackPostNeedsDelete"`
SlackAlertSentAtLeastOnce bool `json:"slackAlertSentAtLeastOnce"`
SlackPostDelayedUntil time.Time `json:"slackPostDelayedUntil"`
// SlackPostPendingSince is set when creating the Slack post failed in a way where the post may still exist,
// e.g. after a timeout, or before the post is created (write-ahead). The post is then looked up in the channel
// history before a new one is created. It is the latest time at which the post may have been created, which is
// in the future for a write-ahead (see [Issue.RegisterSlackPostPendingWriteAhead]). The grace period and max age
// are measured from it. A zero value means that no post is pending.
SlackPostPendingSince time.Time `json:"slackPostPendingSince"`
// The following IsEmoji* fields use "slackPostEmoji*" JSON tags for backward compatibility
// with existing serialized data and external API consumers.
IsEmojiTerminated bool `json:"slackPostEmojiTerminated"`
IsEmojiResolved bool `json:"slackPostEmojiResolved"`
IsEmojiInvestigated bool `json:"slackPostEmojiInvestigated"`
IsEmojiMuted bool `json:"slackPostEmojiMuted"`
IsEmojiButtonsActivated bool `json:"slackPostEmojiButtonsActivated"`
IsMoved bool `json:"isMoved"`
TerminatedByUser string `json:"terminatedByUser"`
ResolvedByUser string `json:"resolvedByUser"`
InvestigatedByUser string `json:"investigatedByUser"`
InvestigatedSince time.Time `json:"investigatedSince"`
MutedByUser string `json:"mutedByUser"`
MutedSince time.Time `json:"mutedSince"`
MoveReason MoveIssueReason `json:"moveReason"`
MovedByUser string `json:"movedByUser"`
IsEscalated bool `json:"isEscalated"`
// PendingPostClick is the post-click state of a clicked webhook button that is not yet delivered.
// See [PostClickState].
PendingPostClick *PostClickState `json:"pendingPostClick,omitempty"`
// PostClick is the active or expired post-click state of a delivered webhook. See [PostClickState].
PostClick *PostClickState `json:"postClick,omitempty"`
// FirstInvestigatedAt is when the issue was first marked as investigated. Unlike InvestigatedSince,
// it is never reset, so it can be used to compute the time to first investigation.
FirstInvestigatedAt time.Time `json:"firstInvestigatedAt"`
// ReopenCount is the number of times the issue went from resolved back to unresolved,
// by a new alert or an unresolve request.
ReopenCount int `json:"reopenCount"`
// contains filtered or unexported fields
}
Issue represents one or more alerts with the same correlation ID (in the same Slack channel). Issues are created when the first alert with a given correlation ID is received, and updated when new alerts arrive with the same correlation ID. Issues can be resolved, archived, and have a connected Slack post.
func NewIssue ¶
NewIssue creates a new Issue from an Alert. Returns nil if the provided alert is nil.
func (*Issue) AddAlert ¶
AddAlert adds a new alert to an existing issue. Alerts that are older than the previous alert are ignored. Alerts with status Resolved are ignored if the issue is already resolved. This method is only relevant for issues that have follow-up enabled. For issues without follow-up, all new alerts are ignored.
Note: This method may mutate the provided alert's Severity field when escalation is active and the current severity is higher than the incoming alert's severity.
The SlackPostDelayedUntil is calculated from issue.Created (not current time) by design, ensuring the issue doesn't appear until the original delay period has elapsed, regardless of how many alerts are added to the issue.
func (*Issue) AddAlertWithReason ¶
AddAlertWithReason works like Issue.AddAlert, and additionally returns the reason the alert was ignored (one of the types.InsightsReason* values for ignored alerts) when it returns false.
func (*Issue) ApplyEscalationRules ¶
func (issue *Issue) ApplyEscalationRules() *EscalationResult
func (*Issue) ApplyWebhookResult ¶ added in v0.19.0
ApplyWebhookResult applies a webhook result command (see CommandActionWebhookResult) to the post-click state.
A result matches the pending post-click state if it has the same webhook ID and click time. A delivered webhook activates the matching pending state, with the after-click settings from the receiving system (if any) replacing the webhook's own. A failed webhook discards the matching pending state.
A delivered webhook with after-click settings from the receiving system is also applied without a pending state (e.g. when the webhook itself has no after-click settings), but only if the click is still the latest: the webhook still exists, no newer click is pending or active, and no alert was received since the click (with a margin for clock skew). An older pending state is then discarded, since the latest click wins.
Other results are ignored, e.g. when an alert was received in the meantime, or the button was clicked again. It returns whether the issue was changed, and whether the Slack post must be updated.
func (*Issue) ArchivedInsightsEvent ¶
func (issue *Issue) ArchivedInsightsEvent(archivedAt time.Time) types.InsightsEvent
ArchivedInsightsEvent returns the types.InsightsEventIssueArchived event for this issue, archived at the given time. The event reason is the Issue.Resolution, and the values hold lifecycle durations and counts.
func (*Issue) ClearPostClickState ¶ added in v0.19.0
ClearPostClickState clears the pending and active/expired post-click state, typically because an alert was received for the issue. It returns whether the issue was changed, and whether the Slack post must be updated.
The fingerprint of the current post is reset when a state is cleared, so that the next post update is not throttled. The alert that clears the state is typically the receiving system's response to the click, and the user who clicked should see it immediately, also when the state was pending (i.e. not shown in the post).
func (*Issue) ClearSlackPostPending ¶ added in v0.17.0
func (issue *Issue) ClearSlackPostPending()
ClearSlackPostPending clears the pending Slack post state, without changing anything else.
func (*Issue) CurrentPostID ¶
func (*Issue) ExpirePostClickState ¶ added in v0.19.0
ExpirePostClickState expires an active post-click state when its reset time has passed, and discards a pending state that never got a result (e.g. a lost result command) within the reset delay plus a grace period. It returns true if the issue was changed. The Slack post is flagged for update when an active state expires.
func (*Issue) FollowUpEnabled ¶
func (*Issue) GetCorrelationID ¶
func (*Issue) GetSlackAction ¶
func (issue *Issue) GetSlackAction() SlackAction
GetSlackAction returns the Slack action needed for this issue
func (*Issue) HasPendingSlackPost ¶ added in v0.17.0
HasPendingSlackPost returns true if the issue has a pending Slack post. See Issue.SlackPostPendingSince.
func (*Issue) HasSlackPost ¶
HasSlackPost returns true if this issue has a connected Slack post at this moment
func (*Issue) InsightsEvent ¶
func (issue *Issue) InsightsEvent(eventType types.InsightsEventType, reason string) types.InsightsEvent
InsightsEvent returns an insights event of the given type and reason, describing this issue in its current channel. Count is set to the issue alert count, and Client to the effective client of the last alert.
func (*Issue) IsFireAndForget ¶ added in v0.25.0
IsFireAndForget returns true if the issue has follow-up disabled. Such an issue is a fire-and-forget notification, kept only briefly to ignore repeated alerts. It is not an issue in any stats sense: it is never counted as open, alerting, resolved or archived, and never produces issue insights events or issue metrics.
func (*Issue) IsInfoOrResolved ¶
func (*Issue) IsLowerPriorityThan ¶
IsLowerPriorityThan returns true if this issue has lower priority than the other issue
func (*Issue) IsReadyForArchiving ¶
IsReadyForArchiving returns true if the issue is ready to be archived
func (*Issue) IsResolved ¶
func (*Issue) IsResolvedAsInconclusive ¶
func (*Issue) IsResolvedAt ¶
IsResolvedAt returns true if the issue is resolved at the given time. An issue with follow-up is resolved from its resolve time (inclusive), so an explicit resolve takes effect immediately.
func (*Issue) IsWebhookHidden ¶ added in v0.19.0
IsWebhookHidden returns true if the button of the webhook with the given ID is hidden by an active post-click state.
func (*Issue) LastAlertHasActiveMentions ¶
LastAlertHasActiveMentions returns true if the last alert has active Slack mentions, that are not muted
func (*Issue) MarshalJSON ¶
func (*Issue) MarshalJSONAndCache ¶
func (*Issue) RegisterArchiving ¶
func (issue *Issue) RegisterArchiving()
RegisterArchiving registers that the issue has been archived
func (*Issue) RegisterHideOptionButtonsRequest ¶
func (issue *Issue) RegisterHideOptionButtonsRequest()
func (*Issue) RegisterInvestigateRequest ¶
func (*Issue) RegisterMoveRequest ¶
func (issue *Issue) RegisterMoveRequest(reason MoveIssueReason, user, newChannelID, newChannelName string)
func (*Issue) RegisterMuteRequest ¶
func (*Issue) RegisterResolveRequest ¶
func (*Issue) RegisterShowOptionButtonsRequest ¶
func (issue *Issue) RegisterShowOptionButtonsRequest()
func (*Issue) RegisterSlackPostAdopted ¶ added in v0.17.0
RegisterSlackPostAdopted registers that a pending Slack post was found in the channel, with the given message timestamp. The post content may be outdated, so the post is flagged for update.
func (*Issue) RegisterSlackPostCreatedOrUpdated ¶
func (issue *Issue) RegisterSlackPostCreatedOrUpdated(slackPostID string, action SlackAction, fingerprint SlackPostFingerprint)
RegisterSlackPostCreatedOrUpdated registers that a Slack post has been created or updated for this issue, with the given fingerprint of the posted content.
func (*Issue) RegisterSlackPostDeleted ¶
func (issue *Issue) RegisterSlackPostDeleted()
RegisterSlackPostDeleted registers that the Slack post connected to this issue has been deleted
func (*Issue) RegisterSlackPostInvalidBlocks ¶
func (issue *Issue) RegisterSlackPostInvalidBlocks()
RegisterSlackPostInvalidBlocks registers that a Slack post could not be created due to invalid blocks (i.e. bad message formatting). It zeros out the Slack post information, but sets the SlackPostNeedsUpdate flag to false, to avoid trying again until the next alert.
func (*Issue) RegisterSlackPostPending ¶ added in v0.17.0
func (issue *Issue) RegisterSlackPostPending()
RegisterSlackPostPending registers that creating the Slack post failed with an unknown outcome, i.e. that the post may still exist. See Issue.SlackPostPendingSince.
func (*Issue) RegisterSlackPostPendingWriteAhead ¶ added in v0.17.0
RegisterSlackPostPendingWriteAhead registers the Slack post as pending before it is created (write-ahead), where maxPostDuration is how long creating the post can take at most. The pending time is set to when the post may have been created at the latest, so that the grace period does not elapse while the post is still being created. See Issue.SlackPostPendingSince.
func (*Issue) RegisterTerminationRequest ¶
RegisterTerminationRequest registers that the Slack post connected to this issue has been marked for termination via Slack reaction/emoji
func (*Issue) RegisterUninvestigateRequest ¶
func (issue *Issue) RegisterUninvestigateRequest()
func (*Issue) RegisterUnmuteRequest ¶
func (issue *Issue) RegisterUnmuteRequest()
func (*Issue) RegisterUnresolveRequest ¶
func (issue *Issue) RegisterUnresolveRequest()
func (*Issue) RegisterWebhookClick ¶ added in v0.19.0
RegisterWebhookClick registers a pending post-click state for the given webhook command, if the webhook has after-click settings. It replaces any previous pending state (the latest click wins), but keeps the current active state until the new click is delivered. It returns true if the issue was changed.
func (*Issue) ResetCachedJSONBody ¶
func (issue *Issue) ResetCachedJSONBody()
func (*Issue) Resolution ¶
Resolution returns how the issue ended (or would end, if archived now), as one of the types.InsightsReason* values used by types.InsightsEventIssueArchived. It is only meaningful for issues with follow-up, since fire-and-forget issues (Issue.IsFireAndForget) are never archived with an insights event.
func (*Issue) SlackPostPendingExpired ¶ added in v0.17.0
SlackPostPendingExpired returns true if more than SlackPostPendingMaxAge has passed since Issue.SlackPostPendingSince.
func (*Issue) SlackPostPendingGraceElapsedAt ¶ added in v0.17.0
SlackPostPendingGraceElapsedAt returns true if, at time t (e.g. when the channel history was read), more than SlackPostPendingGracePeriod had passed since Issue.SlackPostPendingSince.
type ManagerSettingsWrapper ¶
type ManagerSettingsWrapper struct {
// contains filtered or unexported fields
}
ManagerSettingsWrapper wraps the ManagerSettings configuration with thread-safe access. The wrapper allows hot-reloading of settings without passing them around directly. All access to the settings should go through GetSettings() and SetSettings() methods to ensure thread safety during hot-reloading.
func NewManagerSettingsWrapper ¶
func NewManagerSettingsWrapper(settings *config.ManagerSettings) *ManagerSettingsWrapper
NewManagerSettingsWrapper creates a new ManagerSettingsWrapper with the given settings.
func (*ManagerSettingsWrapper) GetSettings ¶
func (w *ManagerSettingsWrapper) GetSettings() *config.ManagerSettings
GetSettings returns the current settings in a thread-safe manner.
func (*ManagerSettingsWrapper) SetSettings ¶
func (w *ManagerSettingsWrapper) SetSettings(settings *config.ManagerSettings)
SetSettings updates the settings in a thread-safe manner.
type MoveIssueReason ¶
type MoveIssueReason string
MoveIssueReason represents the reason for moving an issue between Slack channels.
type MoveMapping ¶
type MoveMapping struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
CorrelationID string `json:"correlationId"`
OriginalChannelID string `json:"originalChannelId"`
TargetChannelID string `json:"targetChannelId"`
Reason MoveIssueReason `json:"reason"`
}
MoveMapping represents information about an issue moved between Slack channels.
func NewMoveMapping ¶
func NewMoveMapping(correlationID, originalChannelID, targetChannelID string, reason MoveIssueReason) *MoveMapping
NewMoveMapping creates a new MoveMapping instance.
func (*MoveMapping) ChannelID ¶
func (m *MoveMapping) ChannelID() string
ChannelID returns the original channel ID of the move mapping, i.e., where the issue was moved from.
func (*MoveMapping) GetCorrelationID ¶
func (m *MoveMapping) GetCorrelationID() string
GetCorrelationID returns the issue correlation ID associated with the move mapping.
func (*MoveMapping) MarshalJSON ¶
func (m *MoveMapping) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface, which is required by the types.MoveMapping interface.
func (*MoveMapping) UniqueID ¶
func (m *MoveMapping) UniqueID() string
UniqueID returns the unique identifier of the move mapping.
type PostClickState ¶ added in v0.19.0
type PostClickState struct {
// WebhookID is the ID of the clicked webhook.
WebhookID string `json:"webhookId"`
// ButtonText is the label of the clicked webhook button.
ButtonText string `json:"buttonText"`
// UserID is the Slack user who clicked the webhook button.
UserID string `json:"userId"`
// UserRealName is the name of the Slack user who clicked the webhook button.
UserRealName string `json:"userRealName"`
// Clicked is the time of the click, i.e. the timestamp of the webhook command. It identifies the click.
Clicked time.Time `json:"clicked"`
// AfterClick is a copy of the webhook's after-click settings at the time of the click.
// StatusText is sanitized (no Slack mentions).
AfterClick types.WebhookAfterClick `json:"afterClick"`
// ExpiresAt is the time when an active state expires. Zero while pending.
ExpiresAt time.Time `json:"expiresAt"`
// Expired is true when the state expired without an alert being received.
Expired bool `json:"expired"`
}
PostClickState is the state of an issue after a webhook button with types.Webhook.AfterClick was clicked.
The lifecycle is:
- Pending (Issue.PendingPostClick): the button was clicked and the webhook is being delivered. Nothing is shown.
- Active (Issue.PostClick, Expired false): the webhook was delivered. Buttons are hidden and a status is shown.
- Expired (Issue.PostClick, Expired true): no alert was received in time. Buttons are shown again, with a note.
Any alert matched to the issue clears both the pending and the active/expired state.
type SlackAction ¶
type SlackAction string
type SlackPostFingerprint ¶ added in v0.22.0
type SlackPostFingerprint struct {
// Significant is a hash of the post parts where a change must be shown immediately: the status (action and
// severity), header, buttons, webhook post-click status, user actions (resolved, investigated, muted) and the
// sender name and icon.
Significant string `json:"significant,omitempty"`
// Content is a hash of the alert content: text, fields, author, host, link, footer and fallback text.
Content string `json:"content,omitempty"`
}
SlackPostFingerprint identifies the content of a Slack post, split by how important a change is to the reader. It is used to decide how soon a post update must be sent (see the Slack client update throttling).
The alert statistics in the post footer (last alert time and alert count) are part of neither hash, since they change with every alert. A post update where both hashes are unchanged only refreshes those statistics.
func (SlackPostFingerprint) IsZero ¶ added in v0.22.0
func (f SlackPostFingerprint) IsZero() bool
IsZero reports whether the fingerprint is unknown, e.g. for a post created before fingerprints were introduced, or an adopted post. An unknown fingerprint never matches another fingerprint.
type WebhookCommandParams ¶
type WebhookCommandParams struct {
WebhookID string `json:"webhookId"`
PlainTextInput map[string]string `json:"plainTextInput,omitempty"`
CheckboxInput map[string][]string `json:"checkboxInput,omitempty"`
// ViewID is the ID of the Slack modal used to confirm the webhook, if any.
// The modal is kept open after submission and updated with the webhook outcome.
// Empty when the webhook was triggered without a confirmation dialog.
ViewID string `json:"viewId,omitempty"`
}
WebhookCommandParams holds parameters specific to webhook commands.
type WebhookOutcome ¶ added in v0.18.0
type WebhookOutcome struct {
// ChannelID is the Slack channel where the webhook button was clicked.
ChannelID string
// UserID is the Slack user who clicked the webhook button.
UserID string
// ViewID is the ID of the confirmation modal, if any. See [WebhookCommandParams.ViewID].
ViewID string
// ButtonText is the label of the clicked webhook button. Empty if unknown.
ButtonText string
// Status is the webhook result.
Status WebhookOutcomeStatus
// Reason is a user-facing explanation of a failure. It must not contain internal details such as target URLs.
// Empty unless Status is [WebhookOutcomeFailed].
Reason string
// Retryable is true if the user may succeed by trying again. Only used when Status is [WebhookOutcomeFailed].
Retryable bool
// Message is an optional message from the receiving system (the Message of a types.WebhookResult), shown as plain
// text. Only used when Status is [WebhookOutcomeDelivered] or [WebhookOutcomeRejected].
Message string
}
WebhookOutcome describes the result of a user-triggered webhook, for feedback to the user who clicked the button.
func NewWebhookOutcome ¶ added in v0.18.0
func NewWebhookOutcome(cmd *Command, buttonText string, status WebhookOutcomeStatus) *WebhookOutcome
NewWebhookOutcome creates a WebhookOutcome with the given status, for the user and confirmation modal (if any) of the given webhook command.
func (*WebhookOutcome) Delivered ¶ added in v0.18.0
func (o *WebhookOutcome) Delivered(message string) *WebhookOutcome
Delivered returns a copy of the outcome with status WebhookOutcomeDelivered and the given (optional) message from the receiving system.
func (*WebhookOutcome) Failed ¶ added in v0.18.0
func (o *WebhookOutcome) Failed(reason string, retryable bool) *WebhookOutcome
Failed returns a copy of the outcome with status WebhookOutcomeFailed and the given reason.
func (*WebhookOutcome) NotifyWithoutModal ¶ added in v0.20.0
func (o *WebhookOutcome) NotifyWithoutModal() bool
NotifyWithoutModal returns true if the user should be informed about the outcome also when there is no confirmation modal to update: failures and rejections, and deliveries with a message from the receiving system. Plain deliveries are not reported, since webhooks without a confirmation dialog are meant to be lightweight.
func (*WebhookOutcome) Rejected ¶ added in v0.20.0
func (o *WebhookOutcome) Rejected(message string) *WebhookOutcome
Rejected returns a copy of the outcome with status WebhookOutcomeRejected and the given (optional) message from the receiving system.
type WebhookOutcomeStatus ¶ added in v0.18.0
type WebhookOutcomeStatus string
WebhookOutcomeStatus is the result of a user-triggered webhook.
type WebhookResultParams ¶ added in v0.19.0
type WebhookResultParams struct {
// WebhookID is the ID of the webhook that was triggered.
WebhookID string `json:"webhookId"`
// Status is the webhook result, i.e. [WebhookOutcomeDelivered] or [WebhookOutcomeFailed].
Status WebhookOutcomeStatus `json:"status"`
// Clicked is the time of the click, i.e. the timestamp of the webhook command. Together with WebhookID,
// it identifies the click.
Clicked time.Time `json:"clicked"`
// Completed is the time when the result was known.
Completed time.Time `json:"completed"`
// AfterClick is the post-click state returned by the receiving system (see types.WebhookResult), if any.
// It overrides the webhook's own after-click settings for this click. Only set when Status is
// [WebhookOutcomeDelivered].
AfterClick *types.WebhookAfterClick `json:"afterClick,omitempty"`
}
WebhookResultParams holds parameters specific to webhook result commands. See CommandActionWebhookResult.