Documentation
¶
Index ¶
- Variables
- type Entry
- type EntryQuery
- type MaintenanceFunc
- type Option
- type Options
- type Silencer
- type Silences
- func (s *Silences) CountState(states ...alert.SilenceState) (int, error)
- func (s *Silences) Expire(id int) error
- func (s *Silences) GC() (int, error)
- func (s *Silences) MarshalBinary() ([]byte, error)
- func (s *Silences) Merge(b []byte) error
- func (s *Silences) Name() string
- func (s *Silences) Query(qs ...EntryQuery) ([]*Entry, int, error)
- func (s *Silences) QueryOne(qs ...EntryQuery) (*Entry, error)
- func (s *Silences) Set(sil *Entry) (int, error)
- func (s *Silences) Start(ctx context.Context) error
- func (s *Silences) Stop(ctx context.Context) error
- func (s *Silences) Version() int
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned if a silence was not found. ErrNotFound = fmt.Errorf("silence not found") )
var ValidateMatcher = func(m *label.Matcher) error { if !label.LabelName(m.Name).IsValid() { return fmt.Errorf("invalid label name %q", m.Name) } switch m.Type { case label.MatchEqual, label.MatchNotEqual: if !utf8.ValidString(m.Value) { return fmt.Errorf("invalid label value %q", m.Value) } case label.MatchRegexp, label.MatchNotRegexp: if _, err := regexp.Compile(m.Value); err != nil { return fmt.Errorf("invalid regular expression %q: %s", m.Value, err) } default: return fmt.Errorf("unknown matcher type %q", m.Type) } return nil }
ValidateMatcher runs validation on the matcher name, type, and pattern.
Functions ¶
This section is empty.
Types ¶
type EntryQuery ¶
func QIDs ¶
func QIDs(ids []int) EntryQuery
func QMatchers ¶
func QMatchers(set label.LabelSet, mc matcherCache) EntryQuery
QMatchers returns a EntryQuery that matches silences with the given.if not found matcher return true
func QState ¶
func QState(now time.Time, states ...alert.SilenceState) EntryQuery
type MaintenanceFunc ¶
type MaintenanceFunc func() error
MaintenanceFunc represents the function to run as part of the periodic maintenance for silences.
type Options ¶
type Options struct { // Retention time for newly created Silences. Silences may be // garbage collected after the given duration after they ended. Retention time.Duration MaintenanceInterval time.Duration MaintenanceFunc MaintenanceFunc DataLoader func(ids ...int) ([]*Entry, error) Spreader members.Spreader }
Options exposes configuration options for creating a new Silences object. Its zero value is a safe default.
type Silencer ¶
type Silencer struct {
// contains filtered or unexported fields
}
Silencer binds together a Marker and a Silences to implement the Muter interface.
func NewSilencer ¶
NewSilencer returns a new Silencer.
type Silences ¶
type Silences struct { Options // contains filtered or unexported fields }
Silences holds a silence state that can be modified, queried, and snapshot.
func NewFromConfiguration ¶
func NewFromConfiguration(cfg *conf.Configuration, opts ...Option) (*Silences, error)
NewFromConfiguration returns a new Silences object with the given configuration.
func (*Silences) CountState ¶
func (s *Silences) CountState(states ...alert.SilenceState) (int, error)
CountState counts silences by state.
func (*Silences) GC ¶
GC runs a garbage collection that removes silences that have ended longer than the configured retention time ago.
func (*Silences) MarshalBinary ¶
func (*Silences) Query ¶
func (s *Silences) Query(qs ...EntryQuery) ([]*Entry, int, error)
Query for silences based on the given query parameters. It returns the resulting silences and the state version the result is based on.
func (*Silences) QueryOne ¶
func (s *Silences) QueryOne(qs ...EntryQuery) (*Entry, error)
QueryOne queries with the given parameters and returns the first result. Returns ErrNotFound if the query result is empty.