-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathsidecar.libsonnet
48 lines (48 loc) · 1.93 KB
/
sidecar.libsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
local thanos = self,
sidecar+:: {
selector: error 'must provide selector for Thanos Sidecar alerts',
thanosPrometheusCommonDimensions: error 'must provide commonDimensions between Thanos and Prometheus metrics for Sidecar alerts',
dimensions: std.join(', ', std.objectFields(thanos.targetGroups) + ['job', 'instance']),
},
prometheusAlerts+:: {
groups+: if thanos.sidecar == null then [] else [
local location = if std.length(std.objectFields(thanos.targetGroups)) > 0 then ' in %s' % std.join('/', ['{{$labels.%s}}' % level for level in std.objectFields(thanos.targetGroups)]) else '';
{
name: 'thanos-sidecar',
rules: [
{
alert: 'ThanosSidecarBucketOperationsFailed',
annotations: {
description: 'Thanos Sidecar {{$labels.instance}}%s bucket operations are failing' % location,
summary: 'Thanos Sidecar bucket operations are failing',
},
expr: |||
sum by (%(dimensions)s) (rate(thanos_objstore_bucket_operation_failures_total{%(selector)s}[5m])) > 0
||| % thanos.sidecar,
'for': '5m',
labels: {
severity: 'critical',
},
},
{
alert: 'ThanosSidecarNoConnectionToStartedPrometheus',
annotations: {
description: 'Thanos Sidecar {{$labels.instance}}%s is unhealthy.' % location,
summary: 'Thanos Sidecar cannot access Prometheus, even though Prometheus seems healthy and has reloaded WAL.',
},
expr: |||
thanos_sidecar_prometheus_up{%(selector)s} == 0
AND on (%(thanosPrometheusCommonDimensions)s)
prometheus_tsdb_data_replay_duration_seconds != 0
||| % thanos.sidecar,
'for': '5m',
labels: {
severity: 'critical',
},
},
],
},
],
},
}