forked from thanos-io/thanos
/
receive.libsonnet
189 lines (189 loc) · 8.14 KB
/
receive.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{
local thanos = self,
receive+:: {
selector: error 'must provide selector for Thanos Receive alerts',
httpErrorThreshold: 5,
ingestionThreshold: 50,
forwardErrorThreshold: 20,
metaMonitoringErrorThreshold: 20,
refreshErrorThreshold: 0,
p99LatencyThreshold: 10,
dimensions: std.join(', ', std.objectFields(thanos.targetGroups) + ['job']),
},
prometheusAlerts+:: {
groups+: if thanos.receive == 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-receive',
rules: [
{
alert: 'ThanosReceiveHttpRequestErrorRateHigh',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s is failing to handle {{$value | humanize}}%% of requests.' % location,
summary: 'Thanos Receive is failing to handle requests.',
},
expr: |||
(
sum by (%(dimensions)s) (rate(http_requests_total{code=~"5..", %(selector)s, handler="receive"}[5m]))
/
sum by (%(dimensions)s) (rate(http_requests_total{%(selector)s, handler="receive"}[5m]))
) * 100 > %(httpErrorThreshold)s
||| % thanos.receive,
'for': '5m',
labels: {
severity: 'critical',
},
},
{
alert: 'ThanosReceiveHttpRequestLatencyHigh',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s has a 99th percentile latency of {{ $value }} seconds for requests.' % location,
summary: 'Thanos Receive has high HTTP requests latency.',
},
expr: |||
(
histogram_quantile(0.99, sum by (%(dimensions)s, le) (rate(http_request_duration_seconds_bucket{%(selector)s, handler="receive"}[5m]))) > %(p99LatencyThreshold)s
and
sum by (%(dimensions)s) (rate(http_request_duration_seconds_count{%(selector)s, handler="receive"}[5m])) > 0
)
||| % thanos.receive,
'for': '10m',
labels: {
severity: 'critical',
},
},
{
alert: 'ThanosReceiveHighReplicationFailures',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s is failing to replicate {{$value | humanize}}%% of requests.' % location,
summary: 'Thanos Receive is having high number of replication failures.',
},
expr: |||
thanos_receive_replication_factor > 1
and
(
(
sum by (%(dimensions)s) (rate(thanos_receive_replications_total{result="error", %(selector)s}[5m]))
/
sum by (%(dimensions)s) (rate(thanos_receive_replications_total{%(selector)s}[5m]))
)
>
(
max by (%(dimensions)s) (floor((thanos_receive_replication_factor{%(selector)s}+1) / 2))
/
max by (%(dimensions)s) (thanos_receive_hashring_nodes{%(selector)s})
)
) * 100
||| % thanos.receive,
'for': '5m',
labels: {
severity: 'warning',
},
},
{
alert: 'ThanosReceiveHighForwardRequestFailures',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s is failing to forward {{$value | humanize}}%% of requests.' % location,
summary: 'Thanos Receive is failing to forward requests.',
},
expr: |||
(
sum by (%(dimensions)s) (rate(thanos_receive_forward_requests_total{result="error", %(selector)s}[5m]))
/
sum by (%(dimensions)s) (rate(thanos_receive_forward_requests_total{%(selector)s}[5m]))
) * 100 > %(forwardErrorThreshold)s
||| % thanos.receive,
'for': '5m',
labels: {
severity: 'info',
},
},
{
alert: 'ThanosReceiveHighHashringFileRefreshFailures',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s is failing to refresh hashring file, {{$value | humanize}} of attempts failed.' % location,
summary: 'Thanos Receive is failing to refresh hasring file.',
},
expr: |||
(
sum by (%(dimensions)s) (rate(thanos_receive_hashrings_file_errors_total{%(selector)s}[5m]))
/
sum by (%(dimensions)s) (rate(thanos_receive_hashrings_file_refreshes_total{%(selector)s}[5m]))
> %(refreshErrorThreshold)s
)
||| % thanos.receive,
'for': '15m',
labels: {
severity: 'warning',
},
},
{
alert: 'ThanosReceiveConfigReloadFailure',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s has not been able to reload hashring configurations.' % location,
summary: 'Thanos Receive has not been able to reload configuration.',
},
expr: 'avg by (%(dimensions)s) (thanos_receive_config_last_reload_successful{%(selector)s}) != 1' % thanos.receive,
'for': '5m',
labels: {
severity: 'warning',
},
},
{
alert: 'ThanosReceiveNoUpload',
annotations: {
description: 'Thanos Receive {{$labels.instance}}%s has not uploaded latest data to object storage.' % location,
summary: 'Thanos Receive has not uploaded latest data to object storage.',
},
expr: |||
(up{%(selector)s} - 1)
+ on (%(dimensions)s, instance) # filters to only alert on current instance last 3h
(sum by (%(dimensions)s, instance) (increase(thanos_shipper_uploads_total{%(selector)s}[3h])) == 0)
||| % thanos.receive,
'for': '3h',
labels: {
severity: 'critical',
},
},
{
alert: 'ThanosReceiveLimitsConfigReloadFailure',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s has not been able to reload the limits configuration.' % location,
summary: 'Thanos Receive has not been able to reload the limits configuration.',
},
expr: 'sum by(%(dimensions)s) (increase(thanos_receive_limits_config_reload_err_total{%(selector)s}[5m])) > 0' % thanos.receive,
'for': '5m',
labels: {
severity: 'warning',
},
},
{
alert: 'ThanosReceiveLimitsHighMetaMonitoringQueriesFailureRate',
annotations: {
description: 'Thanos Receive {{$labels.job}}%s is failing for {{$value | humanize}}%% of meta monitoring queries.' % location,
summary: 'Thanos Receive has not been able to update the number of head series.',
},
// Values are updated every 15s, 20 times over 5 minutes.
expr: '(sum by(%(dimensions)s) (increase(thanos_receive_metamonitoring_failed_queries_total{%(selector)s}[5m])) / 20) * 100 > %(metaMonitoringErrorThreshold)s' % thanos.receive,
'for': '5m',
labels: {
severity: 'warning',
},
},
{
alert: 'ThanosReceiveTenantLimitedByHeadSeries',
annotations: {
description: 'Thanos Receive tenant {{$labels.tenant}}%s is limited by head series.' % location,
summary: 'A Thanos Receive tenant is limited by head series.',
},
expr: 'sum by(%(dimensions)s, tenant) (increase(thanos_receive_head_series_limited_requests_total{%(selector)s}[5m])) > 0' % thanos.receive,
'for': '5m',
labels: {
severity: 'warning',
},
},
],
},
],
},
}