Skip to content
Closed
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
44 changes: 22 additions & 22 deletions internal/k8sprometheus/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,19 +472,18 @@ metadata:
namespace: test-ns
spec:
service: test-svc
preEvaluationRules:
someRule: |
sum_over_time(
(
sum(count by (statefulset)(kube_statefulset_status_replicas_ready{namespace="prometheus-operator", statefulset=~"prometheus-prometheus-operator-prometheus.*"}>0))
/
max(prometheus_operator_spec_shards{namespace="prometheus-operator"}))[{{.window}}:]
)
slos:
- name: slo-with-subquery
objective: 99
sli:
preEvaluationRules:
- name: "someRule"
expr: |
sum_over_time(
(
sum(count by (statefulset)(kube_statefulset_status_replicas_ready{namespace="prometheus-operator", statefulset=~"prometheus-prometheus-operator-prometheus.*"}>0))
/
max(prometheus_operator_spec_shards{namespace="prometheus-operator"}))[{{.window}}:]
)
events:
errorQuery: |
sum_over_time(
Expand Down Expand Up @@ -512,29 +511,30 @@ spec:
TimeWindow: 30 * 24 * time.Hour,
Labels: map[string]string{},
PreEvaluationRules: map[string]string{
"someRule": `
sum_over_time(
(
sum(count by (statefulset)(kube_statefulset_status_replicas_ready{namespace="prometheus-operator", statefulset=~"prometheus-prometheus-operator-prometheus.*"}>0))
/
max(prometheus_operator_spec_shards{namespace="prometheus-operator"}))[{{.window}}:]
)`,
"someRule": `sum_over_time(
(
sum(count by (statefulset)(kube_statefulset_status_replicas_ready{namespace="prometheus-operator", statefulset=~"prometheus-prometheus-operator-prometheus.*"}>0))
/
max(prometheus_operator_spec_shards{namespace="prometheus-operator"}))[{{.window}}:]
)
`,
},
SLI: prometheus.SLI{
Events: &prometheus.SLIEvents{
ErrorQuery: `
sum_over_time(
ErrorQuery: `sum_over_time(
(
sum(count by (statefulset)(kube_statefulset_status_replicas_ready{namespace="prometheus-operator", statefulset=~"prometheus-prometheus-operator-prometheus.*"}>0))
/
max(prometheus_operator_spec_shards{namespace="prometheus-operator"}))[{{.window}}:]
)`,
TotalQuery: `sum_over_time(vector(1) [{{.window}}:])`,
)
`,
TotalQuery: `sum_over_time(vector(1) [{{.window}}:])
`,
},
},
Objective: 99,
PageAlertMeta: prometheus.AlertMeta{Disable: false},
TicketAlertMeta: prometheus.AlertMeta{Disable: false},
PageAlertMeta: prometheus.AlertMeta{Disable: false, Labels: map[string]string{}, Annotations: map[string]string{}},
TicketAlertMeta: prometheus.AlertMeta{Disable: false, Labels: map[string]string{}, Annotations: map[string]string{}},
},
}},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubernetes/api/sloth/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type PrometheusServiceLevelSpec struct {
// RuleDependancy is a set of Prometheus RecordingRules that should
// be executed before the SLO queries are, allowing for SLO defs
// without subqueries
PreEvaluationRules map[string]string
PreEvaluationRules map[string]string `json:"preEvaluationRules,omitempty" yaml:"preEvaluationRules,omitempty"`

// Labels are the Prometheus labels that will have all the recording
// and alerting rules generated for the service SLOs.
Expand Down
Loading