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
1 change: 1 addition & 0 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- 'release-*'
- 'main'
- 'improve-slo-performance-with-subqueries'

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ docker-push:
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.19.0
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
Expand Down
6 changes: 5 additions & 1 deletion jsonnet/controller-gen/pyrra.dev_servicelevelobjectives.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"kind": "CustomResourceDefinition",
"metadata": {
"annotations": {
"controller-gen.kubebuilder.io/version": "v0.18.0"
"controller-gen.kubebuilder.io/version": "v0.19.0"
},
"name": "servicelevelobjectives.pyrra.dev"
},
Expand Down Expand Up @@ -242,6 +242,10 @@
],
"type": "string"
},
"performance_over_accuracy": {
"default": false,
"type": "boolean"
},
"target": {
"description": "Target is a string that's casted to a float64 between 0 - 100.\nIt represents the desired availability of the service in the given window.\nfloat64 are not supported: https://github.com/kubernetes-sigs/controller-tools/issues/245",
"type": "string"
Expand Down
20 changes: 13 additions & 7 deletions kubernetes/api/v1alpha1/servicelevelobjective_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ type ServiceLevelObjectiveSpec struct {
// be ignored by Prometheus instances.
// More info: https://github.com/thanos-io/thanos/blob/main/docs/components/rule.md#partial-response
PartialResponseStrategy string `json:"partial_response_strategy,omitempty"`

// +optional
// +kubebuilder:default:=false
PerformanceOverAccuracy bool `json:"performance_over_accuracy,omitempty"`
}

// ServiceLevelIndicator defines the underlying indicator that is a Prometheus metric.
Expand Down Expand Up @@ -378,6 +382,7 @@ func (in *ServiceLevelObjective) Internal() (slo.Objective, error) {
if err != nil {
return slo.Objective{}, fmt.Errorf("failed to parse objective window: %w", err)
}

var alerting slo.Alerting
alerting.Disabled = false
if in.Spec.Alerting.Disabled != nil {
Expand Down Expand Up @@ -575,13 +580,14 @@ func (in *ServiceLevelObjective) Internal() (slo.Objective, error) {
}

return slo.Objective{
Labels: ls,
Annotations: in.Annotations,
Description: in.Spec.Description,
Target: target / 100,
Window: window,
Config: string(config),
Alerting: alerting,
Labels: ls,
Annotations: in.Annotations,
Description: in.Spec.Description,
Target: target / 100,
Window: window,
PerformanceOverAccuracy: in.Spec.PerformanceOverAccuracy,
Config: string(config),
Alerting: alerting,
Indicator: slo.Indicator{
Ratio: ratio,
Latency: latency,
Expand Down
4 changes: 4 additions & 0 deletions slo/promql.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ func (r objectiveReplacer) replace(node parser.Node) {
n.Range = r.window
}
r.replace(n.VectorSelector)
case *parser.SubqueryExpr:
n.Range = r.window
n.Step = 5 * time.Minute
r.replace(n.Expr)
case *parser.VectorSelector:
if n.Name == "errorMetric" {
n.Name = r.errorMetric
Expand Down
15 changes: 15 additions & 0 deletions slo/promql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ var (
},
}
}
objectiveHTTPRatioGroupingLessAccurate = func() Objective {
o := objectiveHTTPRatio()
o.PerformanceOverAccuracy = true
return o
}
objectiveHTTPRatioGrouping = func() Objective {
o := objectiveHTTPRatio()
o.Indicator.Ratio.Grouping = []string{"job", "handler"}
Expand Down Expand Up @@ -98,6 +103,11 @@ var (
o.Indicator.Ratio.Grouping = []string{"job", "handler"}
return o
}
objectiveGRPCRatioGroupingLessAccuracy = func() Objective {
o := objectiveGRPCRatioGrouping()
o.PerformanceOverAccuracy = true
return o
}
objectiveHTTPLatency = func() Objective {
return Objective{
Labels: labels.FromStrings(labels.MetricName, "monitoring-http-latency"),
Expand Down Expand Up @@ -168,6 +178,11 @@ var (
o.Indicator.Latency.Total.LabelMatchers = append(o.Indicator.Latency.Total.LabelMatchers, matcher)
return o
}
objectiveHTTPLatencyGroupingRegexLessAccuracy = func() Objective {
o := objectiveHTTPLatencyGroupingRegex()
o.PerformanceOverAccuracy = true
return o
}
objectiveGRPCLatency = func() Objective {
return Objective{
Labels: labels.FromStrings(labels.MetricName, "monitoring-grpc-latency"),
Expand Down
Loading
Loading