prometheus

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MetadataRecordingRulesGenerator = metadataRecordingRulesGenerator(false)

MetadataRecordingRulesGenerator knows how to generate the metadata prometheus recording rules from an SLO.

View Source
const YAMLSpecLoader = yamlSpecLoader(false)

YAMLSpecLoader knows how to load YAML specs and converts them to a model.

Variables

View Source
var (
	// ErrNoSLORules will be used when there are no rules to store. The upper layer
	// could ignore or handle the error in cases where there wasn't an output.
	ErrNoSLORules = fmt.Errorf("0 SLO Prometheus rules generated")
)
View Source
var SLIRecordingRulesGenerator = sliRecordingRulesGenerator{/* contains filtered or unexported fields */}

SLIRecordingRulesGenerator knows how to generate the SLI prometheus recording rules form an SLO. Normally these rules are used by the SLO alerts.

View Source
var SLOAlertRulesGenerator = sloAlertRulesGenerator{/* contains filtered or unexported fields */}

SLOAlertRulesGenerator knows how to generate the SLO prometheus alert rules from an SLO.

Functions

This section is empty.

Types

type AlertMeta

type AlertMeta struct {
	Disable     bool
	Name        string            `validate:"required_if_enabled"`
	Labels      map[string]string `validate:"dive,keys,prom_label_key,endkeys,required,prom_label_value"`
	Annotations map[string]string `validate:"dive,keys,prom_annot_key,endkeys,required"`
}

AlertMeta is the metadata of an alert settings.

type IOWriterGroupedRulesYAMLRepo

type IOWriterGroupedRulesYAMLRepo struct {
	// contains filtered or unexported fields
}

IOWriterGroupedRulesYAMLRepo knows to store all the SLO rules (recordings and alerts) grouped in an IOWriter in YAML format, that is compatible with Prometheus.

func NewIOWriterGroupedRulesYAMLRepo

func NewIOWriterGroupedRulesYAMLRepo(writer io.Writer, logger log.Logger) IOWriterGroupedRulesYAMLRepo

func (IOWriterGroupedRulesYAMLRepo) StoreSLOs

func (i IOWriterGroupedRulesYAMLRepo) StoreSLOs(ctx context.Context, slos []StorageSLO) error

StoreSLOs will store the recording and alert prometheus rules, if grouped is false it will split and store as 2 different groups the alerts and the recordings, if true it will be save as a single group.

type SLI

type SLI struct {
	Raw    *SLIRaw
	Events *SLIEvents
}

SLI reprensents an SLI with custom error and total expressions.

type SLIEvents

type SLIEvents struct {
	ErrorQuery string `validate:"required,prom_expr,template_vars"`
	TotalQuery string `validate:"required,prom_expr,template_vars"`
}

type SLIRaw

type SLIRaw struct {
	ErrorRatioQuery string `validate:"required,prom_expr,template_vars"`
}

type SLO

type SLO struct {
	ID               string `validate:"required,name"`
	Name             string `validate:"required,name"`
	Description      string
	Service          string `validate:"required,name"`
	SLI              SLI    `validate:"required"`
	TimeWindow       time.Duration
	Objective        float64           `validate:"gt=0,lte=100"`
	Labels           map[string]string `validate:"dive,keys,prom_label_key,endkeys,required,prom_label_value"`
	PageAlertMeta    AlertMeta
	WarningAlertMeta AlertMeta
}

SLO represents a service level objective configuration.

func (SLO) GetSLIErrorMetric

func (s SLO) GetSLIErrorMetric(window time.Duration) string

GetSLIErrorMetric returns the SLI error metric.

func (SLO) GetSLOIDPromLabels

func (s SLO) GetSLOIDPromLabels() map[string]string

GetSLOIDPromLabels returns the ID labels of an SLO, these can be used to identify an SLO recorded metrics and alerts.

type SLOGroup

type SLOGroup struct {
	SLOs []SLO `validate:"required,dive"`
}

func (SLOGroup) Validate

func (s SLOGroup) Validate() error

Validate validates the SLO.

type SLORules

type SLORules struct {
	SLIErrorRecRules []rulefmt.Rule
	MetadataRecRules []rulefmt.Rule
	AlertRules       []rulefmt.Rule
}

SLORules are the prometheus rules required by an SLO.

type StorageSLO

type StorageSLO struct {
	SLO   SLO
	Rules SLORules
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL