Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add prometheus scrape and rule alerts #118

Merged
merged 1 commit into from
Sep 13, 2024
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
3 changes: 2 additions & 1 deletion common/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ configMapGenerator:
- cert-manager.yaml.tmpl
- daemonset.yaml.tmpl=daemonset.yaml.tmpl
- logging.yaml.tmpl=logging.yaml.tmpl
- metrics.yaml.tmpl
- prometheus.yaml.tmpl
- terraform-applier.yaml.tmpl
- thanos.yaml.tmpl
- vault.yaml.tmpl

- stock/cockroachdb.yaml.tmpl
Expand Down
54 changes: 54 additions & 0 deletions common/prometheus.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# PROMETHEUS RULES
# DO NOT REMOVE line above, used in `pre-commit` hook

groups:
# https://github.com/prometheus/prometheus/tree/main/documentation/prometheus-mixin
- name: prometheus
rules:
# critical
- alert: PrometheusBadConfig
expr: |
# Without max_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
max_over_time(prometheus_config_last_reload_successful{job=~"prometheus.*"}[5m]) == 0
for: 10m
labels:
team: infra
annotations:
summary: "Prometheus {{$labels.monitor}} has failed to reload its configuration."
- alert: PrometheusRuleFailures
expr: |
increase(prometheus_rule_evaluation_failures_total{job=~"prometheus.*"}[5m]) > 0
for: 15m
labels:
team: infra
annotations:
summary: 'Prometheus {{$labels.monitor}} has failed to evaluate {{ printf "%.0f" $value }} rules in the last 5m.'
- alert: PrometheusTargetSyncFailure
expr: |
increase(prometheus_target_sync_failed_total{job=~"prometheus.*"}[30m]) > 0
for: 5m
labels:
team: infra
annotations:
summary: '{{ printf "%.0f" $value }} targets in Prometheus {{$labels.monitor}} have failed to sync because invalid configuration was supplied.'
# warnings
- alert: PrometheusMissingRuleEvaluations
expr: |
increase(prometheus_rule_group_iterations_missed_total{job=~"prometheus.*"}[5m]) > 0
for: 15m
labels:
team: infra
annotations:
summary: 'Prometheus {{$labels.monitor}} has missed {{ printf "%.0f" $value }} rule group evaluations in the last 15m.'
- alert: PrometheusRuleNoEvaluationFor10Intervals
expr: |
time() - max by (monitor, rule_group) (prometheus_rule_group_last_evaluation_timestamp_seconds{job=~"prometheus.*"})
>
10 * max by (monitor, rule_group) (prometheus_rule_group_interval_seconds{job=~"prometheus.*"})
for: 5m
labels:
team: infra
annotations:
summary: Prometheus {{$labels.monitor}} has rule groups that did not evaluate for 10 intervals.
description: The rule group {{$labels.rule_group}} did not evaluate for at least 10x of their expected interval.
10 changes: 5 additions & 5 deletions common/metrics.yaml.tmpl → common/thanos.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ groups:
logs: <https://grafana.$ENVIRONMENT.aws.uw.systems/explore?left=["now-1h","now","Loki",{"expr":"{kubernetes_cluster=\"{{$labels.kubernetes_cluster}}\",kubernetes_namespace=\"{{$labels.kubernetes_namespace}}\",kubernetes_pod_name=~\"{{$labels.kubernetes_pod_name}}\"}"}]|link>
- alert: ThanosNoRuleEvaluations
expr: |
sum by (kubernetes_cluster,kubernetes_namespace,kubernetes_pod_name) (rate(prometheus_rule_evaluations_total{}[5m])) <= 0
sum by (kubernetes_cluster,kubernetes_namespace,kubernetes_pod_name) (rate(prometheus_rule_evaluations_total{app="thanos-rule"}[5m])) <= 0
and
sum by (kubernetes_cluster,kubernetes_namespace,kubernetes_pod_name) (thanos_rule_loaded_rules{}) > 0
for: 5m
Expand All @@ -50,9 +50,9 @@ groups:
- alert: ThanosRuleEvaluationLatencyHigh
expr: |
count by (kubernetes_cluster, kubernetes_namespace, kubernetes_pod_name) (
sum by(kubernetes_cluster,kubernetes_namespace, kubernetes_pod_name, rule_group) (prometheus_rule_group_last_duration_seconds{})
sum by(kubernetes_cluster,kubernetes_namespace, kubernetes_pod_name, rule_group) (prometheus_rule_group_last_duration_seconds{app="thanos-rule"})
>
sum by(kubernetes_cluster, kubernetes_namespace, kubernetes_pod_name, rule_group) (prometheus_rule_group_interval_seconds{})
sum by(kubernetes_cluster, kubernetes_namespace, kubernetes_pod_name, rule_group) (prometheus_rule_group_interval_seconds{app="thanos-rule"})
) > 10
for: 5m
labels:
Expand All @@ -65,9 +65,9 @@ groups:
- alert: ThanosRuleHighRuleEvaluationFailures
expr: |
count by (kubernetes_cluster, kubernetes_namespace, kubernetes_pod_name) (
sum by (kubernetes_cluster,kubernetes_namespace, kubernetes_pod_name, rule_group) (rate(prometheus_rule_evaluation_failures_total{}[5m]))
sum by (kubernetes_cluster,kubernetes_namespace, kubernetes_pod_name, rule_group) (rate(prometheus_rule_evaluation_failures_total{app="thanos-rule"}[5m]))
/
sum by (kubernetes_cluster,kubernetes_namespace, kubernetes_pod_name, rule_group) (rate(prometheus_rule_evaluations_total{}[5m]))
sum by (kubernetes_cluster,kubernetes_namespace, kubernetes_pod_name, rule_group) (rate(prometheus_rule_evaluations_total{app="thanos-rule"}[5m]))
* 100 > 5
) > 10
for: 5m
Expand Down