Documentation ¶
Index ¶
Constants ¶
const MetadataRecordingRulesGenerator = metadataRecordingRulesGenerator(false)
MetadataRecordingRulesGenerator knows how to generate the metadata prometheus recording rules from an SLO.
Variables ¶
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") )
var OptimizedSLIRecordingRulesGenerator = sliRecordingRulesGenerator{/* contains filtered or unexported fields */}
OptimizedSLIRecordingRulesGenerator knows how to generate the SLI prometheus recording rules from an SLO optimizing where it can. Normally these rules are used by the SLO alerts.
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.
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 FileManager ¶
type FileManager interface { FindFiles(ctx context.Context, root string, matcher *regexp.Regexp) (paths []string, err error) ReadFile(ctx context.Context, path string) (data []byte, err error) }
FileManager knows how to manage files.
type FileSLIPluginRepo ¶
type FileSLIPluginRepo struct {
// contains filtered or unexported fields
}
FileSLIPluginRepo will provide the plugins loaded from files. To be able to provide a simple and safe plugin system to the user we have set some rules/requirements that a plugin must implement:
- The plugin must be in a `plugin.go` file inside a directory. - All the plugin must be in the `plugin.go` file. - The plugin can't import anything apart from the Go standard library. - `reflect` and `unsafe` packages can't be used.
These rules provide multiple things: - Easy discovery of plugins without the need to provide extra data (import paths, path sanitization...). - Safety because we don't allow adding external packages easily. - Force keeping the plugins simple, small and without smart code. - Force avoiding DRY in small plugins and embrace WET to have independent plugins.
func NewFileSLIPluginRepo ¶
func NewFileSLIPluginRepo(config FileSLIPluginRepoConfig) (*FileSLIPluginRepo, error)
func (*FileSLIPluginRepo) GetSLIPlugin ¶
func (*FileSLIPluginRepo) ListSLIPlugins ¶
type FileSLIPluginRepoConfig ¶
type FileSLIPluginRepoConfig struct { FileManager FileManager Paths []string Logger log.Logger }
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 SLIPluginRepo ¶
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 `validate:"required"` Objective float64 `validate:"gt=0,lte=100"` Labels map[string]string `validate:"dive,keys,prom_label_key,endkeys,required,prom_label_value"` PageAlertMeta AlertMeta TicketAlertMeta AlertMeta }
SLO represents a service level objective configuration.
func (SLO) GetSLIErrorMetric ¶
GetSLIErrorMetric returns the SLI error metric.
func (SLO) GetSLOIDPromLabels ¶
GetSLOIDPromLabels returns the ID labels of an SLO, these can be used to identify an SLO recorded metrics and alerts.
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 YAMLSpecLoader ¶
type YAMLSpecLoader struct {
// contains filtered or unexported fields
}
YAMLSpecLoader knows how to load YAML specs and converts them to a model.
func NewYAMLSpecLoader ¶
func NewYAMLSpecLoader(pluginsRepo SLIPluginRepo, windowPeriod time.Duration) YAMLSpecLoader
NewYAMLSpecLoader returns a YAML spec loader.
func (YAMLSpecLoader) IsSpecType ¶
func (y YAMLSpecLoader) IsSpecType(ctx context.Context, data []byte) bool