Skip to content
Merged
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
10 changes: 5 additions & 5 deletions autometrics-cli/src/sloth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ slos:
}

fn generate_success_rate_slo(objective_percentile: &str) -> String {
let objective_percentile_no_decimal = objective_percentile.replace(".", "_");
let objective_percentile_no_decimal = objective_percentile.replace('.', "_");

format!(" - name: success-rate-{objective_percentile_no_decimal}
objective: {objective_percentile}
description: Common SLO based on function success rates
sli:
events:
error_query: sum by (objective_name, objective_percentile) (rate(function_calls_count{{objective_percentile=\"{objective_percentile}\",result=\"error\"}}[{{{{.window}}}}]))
total_query: sum by (objective_name, objective_percentile) (rate(function_calls_count{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}]))
total_query: sum by (objective_name, objective_percentile) (rate(function_calls_count{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}])) > 0
alerting:
name: High Error Rate SLO - {objective_percentile}%
labels:
Expand All @@ -72,22 +72,22 @@ fn generate_success_rate_slo(objective_percentile: &str) -> String {
}

fn generate_latency_slo(objective_percentile: &str) -> String {
let objective_percentile_no_decimal = objective_percentile.replace(".", "_");
let objective_percentile_no_decimal = objective_percentile.replace('.', "_");

format!(" - name: latency-{objective_percentile_no_decimal}
objective: {objective_percentile}
description: Common SLO based on function latency
sli:
events:
error_query: >
sum by (objective_name, objective_percentile) (rate(function_calls_duration_bucket{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}]))
sum by (objective_name, objective_percentile) (rate(function_calls_duration_count{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}]))
-
(sum by (objective_name, objective_percentile) (
label_join(rate(function_calls_duration_bucket{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}]), \"autometrics_check_label_equality\", \"\", \"objective_latency_threshold\")
and
label_join(rate(function_calls_duration_bucket{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}]), \"autometrics_check_label_equality\", \"\", \"le\")
))
total_query: sum by (objective_name, objective_percentile) (rate(function_calls_duration_count{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}]))
total_query: sum by (objective_name, objective_percentile) (rate(function_calls_duration_count{{objective_percentile=\"{objective_percentile}\"}}[{{{{.window}}}}])) > 0
alerting:
name: High Latency SLO - {objective_percentile}%
labels:
Expand Down
Loading