Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions internal/k8sprometheus/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ func mapSpecToModel(ctx context.Context, defaultWindowPeriod time.Duration, plug
spec := kspec.Spec
for _, specSLO := range kspec.Spec.SLOs {
slo := prometheus.SLO{
ID: fmt.Sprintf("%s-%s", spec.Service, specSLO.Name),
Name: specSLO.Name,
Description: specSLO.Description,
Service: spec.Service,
TimeWindow: defaultWindowPeriod,
Objective: specSLO.Objective,
Labels: mergeLabels(spec.Labels, specSLO.Labels),
InfoLabels: specSLO.InfoLabels,
PageAlertMeta: prometheus.AlertMeta{Disable: true},
TicketAlertMeta: prometheus.AlertMeta{Disable: true},
ID: fmt.Sprintf("%s-%s", spec.Service, specSLO.Name),
RuleGroupInterval: specSLO.Interval.RuleGroupInterval,
SLIErrorRulesInterval: specSLO.Interval.SLIErrorRulesInterval,
MetadataRulesInterval: specSLO.Interval.MetadataRulesInterval,
AlertRulesInterval: specSLO.Interval.AlertRulesInterval,
Name: specSLO.Name,
Description: specSLO.Description,
Service: spec.Service,
TimeWindow: defaultWindowPeriod,
Objective: specSLO.Objective,
Labels: mergeLabels(spec.Labels, specSLO.Labels),
InfoLabels: specSLO.InfoLabels,
PageAlertMeta: prometheus.AlertMeta{Disable: true},
TicketAlertMeta: prometheus.AlertMeta{Disable: true},
}

// Set SLIs.
Expand Down
18 changes: 18 additions & 0 deletions pkg/kubernetes/api/sloth/v1/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v1

import (
time "time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -81,6 +83,10 @@ type SLO struct {
// Alerting is the configuration with all the things related with the SLO
// alerts.
Alerting Alerting `json:"alerting"`

// Interval is the configuration for all things related to SLO rule_group intervals
// for specific rule groups and all rules.
Interval Interval `yaml:"interval,omitempty"`
}

// SLI will tell what is good or bad for the SLO.
Expand Down Expand Up @@ -171,6 +177,18 @@ type Alert struct {
Annotations map[string]string `json:"annotations,omitempty"`
}

type Interval struct {
// RuleGroupInterval is an optional value for how often the Prometheus rule_group should be evaluated.
// RuleGroupInterval string `yaml:"rulegroup_interval,omitempty"`
RuleGroupInterval time.Duration `yaml:"all,omitempty"`
// Otherwise, specify custom rule_group intervals for each set of recording rules.
// RuleGroupInterval will "fill-in" for any non-specified individual groups
// but individual group settings override RuleGroupInterval.
SLIErrorRulesInterval time.Duration `yaml:"slierror,omitempty"`
MetadataRulesInterval time.Duration `yaml:"metadata,omitempty"`
AlertRulesInterval time.Duration `yaml:"alert,omitempty"`
}

type PrometheusServiceLevelStatus struct {
// PromOpRulesGeneratedSLOs tells how many SLOs have been processed and generated for Prometheus operator successfully.
PromOpRulesGeneratedSLOs int `json:"promOpRulesGeneratedSLOs"`
Expand Down
Loading