Documentation
¶
Index ¶
- Constants
- Variables
- type Alerting
- type AlertingSeverities
- type BoolGaugeIndicator
- type GenerationOptions
- type Indicator
- type IndicatorType
- type LatencyIndicator
- type LatencyNativeIndicator
- type Metric
- type MultiBurnRateAlert
- type Objective
- func (o Objective) AbsentDuration() model.Duration
- func (o Objective) AlertName() string
- func (o Objective) AlertNameAbsent() string
- func (o Objective) Alerts() ([]MultiBurnRateAlert, error)
- func (o Objective) Burnrate(timerange time.Duration, opts GenerationOptions) string
- func (o Objective) BurnrateName(rate time.Duration) string
- func (o Objective) Burnrates(opts GenerationOptions) (monitoringv1.RuleGroup, error)
- func (o Objective) DurationRange(timerange time.Duration, percentile float64) string
- func (o Objective) ErrorsRange(timerange time.Duration, opts GenerationOptions) string
- func (o Objective) Exhausts(factor float64) model.Duration
- func (o Objective) GenericRules(opts GenerationOptions) (monitoringv1.RuleGroup, error)
- func (o Objective) Grouping() []string
- func (o Objective) HasWindows(short, long model.Duration) (Window, bool)
- func (o Objective) IncreaseRules(opts GenerationOptions) (monitoringv1.RuleGroup, error)
- func (o Objective) IndicatorType() IndicatorType
- func (o Objective) Name() string
- func (o Objective) QueryBurnrate(timerange time.Duration, groupingMatchers []*labels.Matcher) (string, error)
- func (o Objective) QueryErrorBudget(opts GenerationOptions) string
- func (o Objective) QueryErrors(window model.Duration, opts GenerationOptions) string
- func (o Objective) QueryTotal(window model.Duration, opts GenerationOptions) string
- func (o Objective) RequestRange(timerange time.Duration, opts GenerationOptions) string
- func (o Objective) SplitIncreaseRules(opts GenerationOptions) (short, long monitoringv1.RuleGroup, err error)
- func (o Objective) Windows() []Window
- type RatioIndicator
- type RuleOutput
- type Window
Constants ¶
const ( // PropagationLabelsPrefix provides a way to propagate labels from the // ObjectMeta to the PrometheusRule. PropagationLabelsPrefix = "pyrra.dev/" )
Variables ¶
var ErrGroupingUnsupported = errors.New("objective with grouping not supported in generic rules")
Functions ¶
This section is empty.
Types ¶
type AlertingSeverities ¶ added in v0.10.0
type BoolGaugeIndicator ¶ added in v0.6.0
type GenerationOptions ¶ added in v0.10.0
type GenerationOptions struct {
// EnablePrometheus3Migration enables generation of rules compatible with both
// Prometheus 2 and 3. This transforms le label matchers from exact matches
// (e.g., le="1") to regex matches (e.g., le=~"1(\.0)?") to handle the
// Prometheus 3 change where classic histogram bucket labels are normalized to floats.
// This only affects classic histograms (Latency indicators); native histograms
// (LatencyNative indicators) are not affected by this change.
EnablePrometheus3Migration bool
// ExternalURL is the base URL for Pyrra, used to generate direct links to the
// Pyrra UI in alert annotations (pyrra_url annotation).
ExternalURL string
}
GenerationOptions contains configuration for rule generation.
type Indicator ¶
type Indicator struct {
Ratio *RatioIndicator
Latency *LatencyIndicator
LatencyNative *LatencyNativeIndicator
BoolGauge *BoolGaugeIndicator
}
type IndicatorType ¶ added in v0.6.0
type IndicatorType int
const ( Unknown IndicatorType = iota Ratio IndicatorType = iota Latency IndicatorType = iota LatencyNative IndicatorType = iota BoolGauge IndicatorType = iota )
type LatencyIndicator ¶
type LatencyNativeIndicator ¶ added in v0.7.0
type MultiBurnRateAlert ¶
type Objective ¶
type Objective struct {
Labels labels.Labels
Annotations map[string]string
Description string
Target float64
Window model.Duration
Config string
PerformanceOverAccuracy bool
RuleOutput RuleOutput
Alerting Alerting
Indicator Indicator
}
func (Objective) AbsentDuration ¶ added in v0.6.3
AbsentDuration calculates the duration when absent alerts should fire. The idea is as follows: Use the most critical of the multi burn rate alerts. For that alert to fire, both the short AND long windows have to be above the threshold. The long window takes the - longest - to fire. Assuming absence of the metric means 100% error rate, the time it takes to fire is the duration for the long window to go above the threshold (factor * objective). Finally, we add the "for" duration we add to the multi burn rate alerts.
func (Objective) AlertNameAbsent ¶ added in v0.8.0
func (Objective) Alerts ¶
func (o Objective) Alerts() ([]MultiBurnRateAlert, error)
func (Objective) Burnrate ¶
func (o Objective) Burnrate(timerange time.Duration, opts GenerationOptions) string
func (Objective) BurnrateName ¶ added in v0.4.3
func (Objective) Burnrates ¶
func (o Objective) Burnrates(opts GenerationOptions) (monitoringv1.RuleGroup, error)
func (Objective) DurationRange ¶ added in v0.5.0
func (Objective) ErrorsRange ¶
func (o Objective) ErrorsRange(timerange time.Duration, opts GenerationOptions) string
func (Objective) GenericRules ¶ added in v0.5.0
func (o Objective) GenericRules(opts GenerationOptions) (monitoringv1.RuleGroup, error)
func (Objective) HasWindows ¶ added in v0.4.0
func (Objective) IncreaseRules ¶ added in v0.3.0
func (o Objective) IncreaseRules(opts GenerationOptions) (monitoringv1.RuleGroup, error)
IncreaseRules returns a single RuleGroup with all increase rules.
func (Objective) IndicatorType ¶ added in v0.6.0
func (o Objective) IndicatorType() IndicatorType
func (Objective) QueryBurnrate ¶ added in v0.4.3
func (Objective) QueryErrorBudget ¶
func (o Objective) QueryErrorBudget(opts GenerationOptions) string
func (Objective) QueryErrors ¶
func (o Objective) QueryErrors(window model.Duration, opts GenerationOptions) string
QueryErrors returns a PromQL query to get the amount of request errors during the window.
func (Objective) QueryTotal ¶
func (o Objective) QueryTotal(window model.Duration, opts GenerationOptions) string
QueryTotal returns a PromQL query to get the total amount of requests served during the window.
func (Objective) RequestRange ¶
func (o Objective) RequestRange(timerange time.Duration, opts GenerationOptions) string
func (Objective) SplitIncreaseRules ¶ added in v0.10.0
func (o Objective) SplitIncreaseRules(opts GenerationOptions) (short, long monitoringv1.RuleGroup, err error)
SplitIncreaseRules returns two separate rule groups when PerformanceOverAccuracy is enabled:
- short: 5m increase recording rules and absent alerts (run on Prometheus)
- long: subquery rules over the full window (run on Thanos)
When PerformanceOverAccuracy is false, short is empty and long contains all rules.