Documentation ¶
Index ¶
- Variables
- func IsDigit(s string) bool
- type Command
- func (c Command) Equal(other *Command) bool
- func (c Command) Fingerprint(alert *template.Alert) (string, bool)
- func (c Command) Matches(alert *template.Alert) bool
- func (c Command) ParseSignal() (os.Signal, error)
- func (c Command) Run(out chan<- CommandResult, quit chan struct{}, done chan struct{}, ...)
- func (c Command) ShouldIgnoreResolved() bool
- func (c Command) ShouldNotify() bool
- func (c Command) String() string
- func (c Command) WithEnv(env ...string) *exec.Cmd
- type CommandResult
- type Result
Constants ¶
This section is empty.
Variables ¶
var ( ResultStrings = map[Result]string{ CmdOk: "Ok", CmdFail: "Fail", CmdSigOk: "SigOk", CmdSigFail: "SigFail", CmdSkipSig: "SkipSig", } )
Functions ¶
Types ¶
type Command ¶
type Command struct { Cmd string `yaml:"cmd"` Args []string `yaml:"args"` // Only execute this command when all of the given labels match. // The CommonLabels field of prometheus alert data is used for comparison. MatchLabels map[string]string `yaml:"match_labels"` // How many instances of this command can run at the same time. // A zero or negative value is interpreted as 'no limit'. Max int `yaml:"max"` // Whether we should let the caller know if a command failed. // Defaults to true. // The value is a pointer to bool with the 'omitempty' tag, // so we can tell when the value was not defined, // meaning we'll provide the default value. NotifyOnFailure *bool `yaml:"notify_on_failure,omitempty"` // Whether command will ignore a 'resolved' notification for a matching command, // and continue running to completion. // Defaults to false. IgnoreResolved *bool `yaml:"ignore_resolved,omitempty"` ResolvedSig string `yaml:"resolved_signal"` // Evaluate if terraform destroy should be run DestroyOnResolved *bool `yaml:"destroy_on_resolved,omitempty"` // Available scheduling modes based on alert status // Regular, firing -> apply, resolved -> destroy // Sawtooth, firing -> apply, resolved -> ignore TerraformScheduling string `yaml:"terraform_scheduling,omitempty"` }
Command represents a command that could be run based on what labels match
func (Command) Fingerprint ¶
Fingerprint returns the fingerprint of the first alarm that matches the command's labels. The first fingerprint found is returned if we have no MatchLabels defined.
func (Command) Matches ¶
Matches returns true if the specified labels in MatchLabels are present and match their values in the prometheus alert message. If MatchLabels is empty, it returns true.
func (Command) ParseSignal ¶
ParseSignal returns the signal that is meant to be used for notifying the command that its triggering condition has resolved, and any error encountered while parsing.
func (Command) Run ¶
func (c Command) Run(out chan<- CommandResult, quit chan struct{}, done chan struct{}, env ...string)
Run executes the command, potentially signalling it if alarm that triggered command resolves. out channel is used to indicate the result of running or killing the program. May indicate errors. quit channel is used to determine if execution should quit early done channel is used to indicate to caller when execution has completed
func (Command) ShouldIgnoreResolved ¶
ShouldIgnoreResolved returns the interpreted value of c.IgnoreResolved. This method is used to work around ambiguity of unmarshalling yaml boolean values, due to the default value of a bool being false.
func (Command) ShouldNotify ¶
ShouldNotify returns the interpreted value of c.NotifyOnFailure. This method is used to work around ambiguity of unmarshalling yaml boolean values, due to the default value of a bool being false.