Documentation ¶
Index ¶
- func RegisterAlertFilter(name string, constructor AlertFilterConstructor)
- func RegisterAlertStatsQuery(name string, constructor alertStatsQueryConstructor)
- func SortAlertsByFields(alerts []model.Alert, fields []string, order Order) sort.Interface
- type AlertCountQuery
- type AlertFilter
- type AlertFilterConstructor
- type AlertFilterFunc
- type AlertQuery
- type AlertStatsQuery
- type AlertStatusCountQuery
- type AllFilter
- type AllMatchFilter
- type ExactLabelMatchFilter
- type IDFilter
- type LastNotifyTimeRangeFilter
- type MatcherFilter
- type Order
- type PartialLabelMatchFilter
- type Query
- type QueryOpFunc
- type QueryOption
- type SilenceFilter
- type SilenceFilterFunc
- type SilenceQuery
- type StatsResult
- type StatusFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterAlertFilter ¶
func RegisterAlertFilter(name string, constructor AlertFilterConstructor)
func RegisterAlertStatsQuery ¶
func RegisterAlertStatsQuery(name string, constructor alertStatsQueryConstructor)
RegisterAlertStatsQuery registers a new AlertStatsQuery.
Types ¶
type AlertCountQuery ¶
type AlertCountQuery struct {
// contains filtered or unexported fields
}
AlertCountQuery counts the number of alerts that match the filter.
func (*AlertCountQuery) Filter ¶
func (q *AlertCountQuery) Filter() AlertFilter
func (*AlertCountQuery) Gather ¶
func (q *AlertCountQuery) Gather(ctx context.Context) []StatsResult
type AlertFilter ¶
type AlertFilter interface { Type() string MatchesAlert(ctx context.Context, alert *model.Alert) bool }
AlertFilter is a query that can be run against a DB to pull things out of it.
func ExactLabelMatch ¶
func ExactLabelMatch(labels model.Labels) AlertFilter
func UnmarshalAlertFilter ¶
func UnmarshalAlertFilter(args map[string]string) (AlertFilter, error)
UnmarshalAlertFilter unmarshals an AlertFilter from a set of arguments.
type AlertFilterConstructor ¶
type AlertFilterConstructor func(args map[string]string) AlertFilter
AlertFilterConstructor is a function that can construct an AlertFilter from a set of arguments.
type AlertFilterFunc ¶
func (AlertFilterFunc) MatchesAlert ¶
func (AlertFilterFunc) Type ¶
func (a AlertFilterFunc) Type() string
type AlertQuery ¶
type AlertQuery struct { Query Filter AlertFilter }
func NewAlertQuery ¶
func NewAlertQuery(filter AlertFilter, ops ...QueryOption) AlertQuery
type AlertStatsQuery ¶
type AlertStatsQuery interface { // Filter returns the filter that this filters the data that gets passed to Process(). Filter() AlertFilter // Process is called for each alert that matches the filter. Process(ctx context.Context, alert *model.Alert) error // Gather is called after all alerts have been processed. It returns the results of the query. Gather(ctx context.Context) []StatsResult }
AlertStatsQuery is a query that can be run against a DB to pull aggregated numbers out of it.
func NewAlertCountQuery ¶
func NewAlertCountQuery(args map[string]string) (AlertStatsQuery, error)
func NewAlertStatusCountQuery ¶
func NewAlertStatusCountQuery(args map[string]string) (AlertStatsQuery, error)
func UnmarshalAlertStatsQuery ¶
func UnmarshalAlertStatsQuery(ty string, args map[string]string) (AlertStatsQuery, error)
UnmarshalAlertStatsQuery unmarshals an AlertStatsQuery from a set of arguments.
type AlertStatusCountQuery ¶
type AlertStatusCountQuery struct {
// contains filtered or unexported fields
}
AlertStatusCountQuery counts the number of alerts, grouped by status.
func (*AlertStatusCountQuery) Filter ¶
func (q *AlertStatusCountQuery) Filter() AlertFilter
func (*AlertStatusCountQuery) Gather ¶
func (q *AlertStatusCountQuery) Gather(ctx context.Context) []StatsResult
type AllFilter ¶
type AllFilter struct {
// contains filtered or unexported fields
}
func AllAlerts ¶
func AllAlerts(queries ...AlertFilter) *AllFilter
func AllSilences ¶
func AllSilences(queries ...SilenceFilter) *AllFilter
func (*AllFilter) MatchesAlert ¶
func (*AllFilter) MatchesSilence ¶
type AllMatchFilter ¶
type AllMatchFilter struct{}
AllMatchFilter is a query that returns every alert.
func MatchAll ¶
func MatchAll() *AllMatchFilter
func (*AllMatchFilter) MatchesAlert ¶
func (*AllMatchFilter) MatchesSilence ¶
func (*AllMatchFilter) Type ¶
func (a *AllMatchFilter) Type() string
type ExactLabelMatchFilter ¶
ExactLabelMatchFilter is an AlertFilter that matches alerts that contain exactly the given labelset.
func (*ExactLabelMatchFilter) MatchesAlert ¶
func (*ExactLabelMatchFilter) Type ¶
func (e *ExactLabelMatchFilter) Type() string
type IDFilter ¶
type IDFilter struct {
ID string
}
IDFilter is a query that matches a specific alert or silence by ID.
func (*IDFilter) MatchesAlert ¶
func (*IDFilter) MatchesSilence ¶
type LastNotifyTimeRangeFilter ¶
func LastNotifyTimeMax ¶
func LastNotifyTimeMax(maxTime time.Time) *LastNotifyTimeRangeFilter
func LastNotifyTimeMin ¶
func LastNotifyTimeMin(minTime time.Time) *LastNotifyTimeRangeFilter
func LastNotifyTimeWithin ¶
func LastNotifyTimeWithin(minTime, maxTime time.Time) *LastNotifyTimeRangeFilter
func (*LastNotifyTimeRangeFilter) MatchesAlert ¶
func (*LastNotifyTimeRangeFilter) Type ¶
func (l *LastNotifyTimeRangeFilter) Type() string
type MatcherFilter ¶
type MatcherFilter struct {
// contains filtered or unexported fields
}
MatcherFilter is a Filter that matches alerts or silences that contain the given matcher.
func Matcher ¶
func Matcher(m model.Matcher) *MatcherFilter
func (*MatcherFilter) MatchesAlert ¶
MatchesAlert returns true if the given matcher matcher the given alert.
func (*MatcherFilter) MatchesSilence ¶
MatchesSilence returns true if the given matcher is in the given silence.
func (*MatcherFilter) Type ¶
func (i *MatcherFilter) Type() string
type PartialLabelMatchFilter ¶
PartialLabelMatchFilter is an AlertFilter that matches alerts that contain the given labels (but may have extras on top of these).
func PartialLabelMatch ¶
func PartialLabelMatch(labels model.Labels) *PartialLabelMatchFilter
func (*PartialLabelMatchFilter) MatchesAlert ¶
func (*PartialLabelMatchFilter) MatchesSilence ¶
func (*PartialLabelMatchFilter) Type ¶
func (p *PartialLabelMatchFilter) Type() string
type Query ¶
type Query struct { // OrderBy is a direction to order the results by. Order Order // OrderBy is a list of fields to order the results by. OrderBy []string // Offset is the number of results to skip before returning results. Offset int // Limit is the maximum number of results to return. Limit int }
Query represents a generic query based on SQL semantics.
type QueryOpFunc ¶
type QueryOpFunc func(*Query)
func (QueryOpFunc) Apply ¶
func (f QueryOpFunc) Apply(q *Query)
type QueryOption ¶
type QueryOption interface {
Apply(*Query)
}
QueryOption represents an option that can be applied to a query.
func Limit ¶
func Limit(limit int) QueryOption
func Offset ¶
func Offset(offset int) QueryOption
func OrderBy ¶
func OrderBy(fields []string, order Order) QueryOption
type SilenceFilter ¶
SilenceFilter is a query that can be run against a DB to pull things out of it.
func SilenceIsActive ¶
func SilenceIsActive() SilenceFilter
SilenceIsActive returns a SilenceFilter that matches only active silences.
type SilenceFilterFunc ¶
func (SilenceFilterFunc) MatchesSilence ¶
type SilenceQuery ¶
type SilenceQuery struct { Query Filter SilenceFilter }
func NewSilenceQuery ¶
func NewSilenceQuery(filter SilenceFilter, ops ...QueryOption) SilenceQuery
type StatsResult ¶
type StatsResult struct { // Labels are the labels that apply to this result. Labels map[string]string `json:"labels"` // Frames are the data frames that apply to this result. Frames [][]float64 `json:"frames"` }
StatsResult is a single result from a StatsQuery.
type StatusFilter ¶
type StatusFilter struct {
Status model.AlertStatus
}
StatusFilter returns all the alerts that match the given status.
func Status ¶
func Status(s model.AlertStatus) *StatusFilter
func (*StatusFilter) MatchesAlert ¶
func (*StatusFilter) Type ¶
func (s *StatusFilter) Type() string