Skip to content

Commit

Permalink
feat: added slo duplicates check during validate
Browse files Browse the repository at this point in the history
Issue slok#493
  • Loading branch information
r3code authored Apr 10, 2023
1 parent 609d244 commit af20bae
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
version: "prometheus/v1"
service: "svc01"
labels:
global01k1: global01v1
slos:
- name: "slo1"
objective: 99.9
description: "This is SLO 01."
labels:
global02k1: global02v1
sli:
events:
error_query: sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
total_query: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
name: myServiceAlert
labels:
alert01k1: "alert01v1"
annotations:
alert02k1: "alert02k2"
pageAlert:
labels:
alert03k1: "alert03v1"
ticketAlert:
labels:
alert04k1: "alert04v1"
- name: "slo02"
objective: 95
description: "This is SLO 02."
labels:
global03k1: global03v1
sli:
raw:
error_ratio_query: |
sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
/
sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
page_alert:
disable: true
ticket_alert:
disable: true

---
version: "prometheus/v1"
service: "svc01"
labels:
global01k1: global01v1
slos:
- name: "slo1" # duplicate
objective: 99.9
description: "This is SLO 01."
labels:
global02k1: global02v1
sli:
events:
error_query: sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
total_query: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
name: myServiceAlert
labels:
alert01k1: "alert01v1"
annotations:
alert02k1: "alert02k2"
pageAlert:
labels:
alert03k1: "alert03v1"
ticketAlert:
labels:
alert04k1: "alert04v1"
- name: "slo02" # duplicate
objective: 95
description: "This is SLO 02."
labels:
global03k1: global03v1
sli:
raw:
error_ratio_query: |
sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
/
sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
page_alert:
disable: true
ticket_alert:
disable: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: sloth.slok.dev/v1
kind: PrometheusServiceLevel
metadata:
name: svc
namespace: test-ns
spec:
service: "svc01"
labels:
global01k1: global01v1
slos:
- name: "slo1"
objective: 99.9
description: "This is SLO 01."
labels:
global02k1: global02v1
sli:
events:
errorQuery: sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
totalQuery: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
name: myServiceAlert
labels:
alert01k1: "alert01v1"
annotations:
alert02k1: "alert02k2"
pageAlert:
labels:
alert03k1: "alert03v1"
ticketAlert:
labels:
alert04k1: "alert04v1"
- name: "slo02"
objective: 95
description: "This is SLO 02."
labels:
global03k1: global03v1
sli:
raw:
errorRatioQuery: |
sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
/
sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
pageAlert:
disable: true
ticketAlert:
disable: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: sloth.slok.dev/v1
kind: PrometheusServiceLevel
metadata:
name: svc
namespace: test-ns
spec:
service: "svc01"
labels:
global01k1: global01v1
slos:
- name: "slo1"
objective: 99.9
description: "This is SLO 01."
labels:
global02k1: global02v1
sli:
events:
errorQuery: sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
totalQuery: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
name: myServiceAlert
labels:
alert01k1: "alert01v1"
annotations:
alert02k1: "alert02k2"
pageAlert:
labels:
alert03k1: "alert03v1"
ticketAlert:
labels:
alert04k1: "alert04v1"
- name: "slo02"
objective: 95
description: "This is SLO 02."
labels:
global03k1: global03v1
sli:
raw:
errorRatioQuery: |
sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
/
sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
pageAlert:
disable: true
ticketAlert:
disable: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: openslo/v1alpha
kind: SLO
metadata:
name: slo1
displayName: Integration test SLO1
spec:
service: svc01
description: "this is SLO1."
budgetingMethod: Occurrences
objectives:
- ratioMetrics:
good:
source: prometheus
queryType: promql
query: sum(rate(http_request_duration_seconds_count{job="myservice",code!~"(5..|429)"}[{{.window}}]))
total:
source: prometheus
queryType: promql
query: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
target: 0.999
timeWindows:
- count: 30
unit: Day
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: openslo/v1alpha
kind: SLO
metadata:
name: slo1
displayName: Integration test SLO1
spec:
service: svc01
description: "this is SLO1."
budgetingMethod: Occurrences
objectives:
- ratioMetrics:
good:
source: prometheus
queryType: promql
query: sum(rate(http_request_duration_seconds_count{job="myservice",code!~"(5..|429)"}[{{.window}}]))
total:
source: prometheus
queryType: promql
query: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
target: 0.999
timeWindows:
- count: 30
unit: Day
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "prometheus/v1"
service: "svc01"
labels:
global01k1: global01v1
slos:
- name: "slo1"
objective: 99.9
description: "This is SLO 01."
labels:
global02k1: global02v1
sli:
events:
error_query: sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
total_query: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
name: myServiceAlert
labels:
alert01k1: "alert01v1"
annotations:
alert02k1: "alert02k2"
pageAlert:
labels:
alert03k1: "alert03v1"
ticketAlert:
labels:
alert04k1: "alert04v1"
- name: "slo02"
objective: 95
description: "This is SLO 02."
labels:
global03k1: global03v1
sli:
raw:
error_ratio_query: |
sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
/
sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
page_alert:
disable: true
ticket_alert:
disable: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "prometheus/v1"
service: "svc01"
labels:
global01k1: global01v1
slos:
- name: "slo1"
objective: 99.9
description: "This is SLO 01."
labels:
global02k1: global02v1
sli:
events:
error_query: sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
total_query: sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
name: myServiceAlert
labels:
alert01k1: "alert01v1"
annotations:
alert02k1: "alert02k2"
pageAlert:
labels:
alert03k1: "alert03v1"
ticketAlert:
labels:
alert04k1: "alert04v1"
- name: "slo02"
objective: 95
description: "This is SLO 02."
labels:
global03k1: global03v1
sli:
raw:
error_ratio_query: |
sum(rate(http_request_duration_seconds_count{job="myservice",code=~"(5..|429)"}[{{.window}}]))
/
sum(rate(http_request_duration_seconds_count{job="myservice"}[{{.window}}]))
alerting:
page_alert:
disable: true
ticket_alert:
disable: true
Loading

0 comments on commit af20bae

Please sign in to comment.