forked from Altinity/clickhouse-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prometheus-alert-rules-backup.yaml
252 lines (218 loc) · 26.6 KB
/
prometheus-alert-rules-backup.yaml
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
prometheus: prometheus
role: alert-rules
name: prometheus-clickhouse-backup-rules
spec:
groups:
- name: ClickHouseBackupRules
rules:
- alert: ClickHouseBackupDown
expr: up{container_name='clickhouse-backup'} == 0
labels:
severity: critical
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup possible down"
description: |-
`clickhouse-backup` can't be scraped via prometheus.
Check clickhouse-backup status
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```
- alert: ClickHouseBackupRecentlyRestart
expr: (clickhouse_backup_last_backup_success{container_name='clickhouse-backup'} == 2 or clickhouse_backup_last_create_status{container_name='clickhouse-backup'} == 2) and time() - process_start_time_seconds{container_name='clickhouse-backup'} < 180
labels:
severity: warning
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup restart less than 3 minutes ago"
description: |-
`clickhouse-backup` possible was restarted
Check clickhouse-backup status
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```
- alert: ClickHouseBackupFailed
expr: |-
(increase(clickhouse_backup_failed_backups{container_name='clickhouse-backup'}[24h]) > 0 and clickhouse_backup_last_backup_success != 1)
or (clickhouse_backup_last_backup_success{container_name='clickhouse-backup'} == 0)
or (increase(clickhouse_backup_failed_creates{container_name='clickhouse-backup'}[24h]) > 0 and clickhouse_backup_last_create_status != 1)
or (clickhouse_backup_last_create_status{container_name='clickhouse-backup'} == 0)
or (increase(clickhouse_backup_failed_downloads{container_name='clickhouse-backup'}[24h]) > 0 and clickhouse_backup_last_download_status != 1)
or (clickhouse_backup_last_download_status{container_name='clickhouse-backup'} == 0)
or (increase(clickhouse_backup_failed_restores{container_name='clickhouse-backup'}[24h]) > 0 and clickhouse_backup_last_restore_status != 1)
or (clickhouse_backup_last_restore_status{container_name='clickhouse-backup'} == 0)
or (increase(clickhouse_backup_failed_uploads{container_name='clickhouse-backup'}[24h]) > 0 and clickhouse_backup_last_upload_status != 1)
or (clickhouse_backup_last_upload_status{container_name='clickhouse-backup'} == 0)
or (increase(clickhouse_backup_failed_create_remotes{container_name='clickhouse-backup'}[24h]) > 0 and clickhouse_backup_last_create_remote_status != 1)
or (clickhouse_backup_last_create_remote_status{container_name='clickhouse-backup'} == 0)
or (increase(clickhouse_backup_failed_restore_remotes{container_name='clickhouse-backup'}[24h]) > 0 and clickhouse_backup_last_restore_remote_status != 1)
or (clickhouse_backup_last_restore_remote_status{container_name='clickhouse-backup'} == 0)
labels:
severity: critical
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup last backup possible failed"
description: |-
status legend
- 0 - failed
- 1 - success
- 2 - unknown
`increase(clickhouse_backup_failed_create_remotes{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}[24h])` = {{ with printf "increase(clickhouse_backup_failed_create_remotes{pod_name='%s',namespace='%s'}[24h])" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }}
`clickhouse_backup_last_create_remote_status{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_create_remote_status{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.0f" }}{{ end }}
`increase(clickhouse_backup_failed_restore_remotes{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}[24h])` = {{ with printf "increase(clickhouse_backup_failed_restore_remotes{pod_name='%s',namespace='%s'}[24h])" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }}
`clickhouse_backup_last_restore_remote_status{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_restore_remote_status{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.0f" }}{{ end }}
`increase(clickhouse_backup_failed_backups{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}[24h])` = {{ with printf "increase(clickhouse_backup_failed_backups{pod_name='%s',namespace='%s'}[24h])" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }}
`clickhouse_backup_last_backup_success{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_backup_success{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.0f" }}{{ end }}
`increase(clickhouse_backup_failed_creates{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}[24h])` = {{ with printf "increase(clickhouse_backup_failed_creates{pod_name='%s',namespace='%s'}[24h])" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }}
`clickhouse_backup_last_create_status{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_create_status{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.0f" }}{{ end }}
`increase(clickhouse_backup_failed_downloads{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}[24h])` = {{ with printf "increase(clickhouse_backup_failed_downloads{pod_name='%s',namespace='%s'}[24h])" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }}
`clickhouse_backup_last_download_status{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_download_status{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.0f" }}{{ end }}
`increase(clickhouse_backup_failed_restores{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}[24h])` = {{ with printf "increase(clickhouse_backup_failed_restores{pod_name='%s',namespace='%s'}[24h])" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }}
`clickhouse_backup_last_restore_status{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_restore_status{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.0f" }}{{ end }}
`increase(clickhouse_backup_failed_uploads{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}[24h])` = {{ with printf "increase(clickhouse_backup_failed_uploads{pod_name='%s',namespace='%s'}[24h])" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }}
`clickhouse_backup_last_upload_status{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_upload_status{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.0f" }}{{ end }}
Check clickhouse-backup logs
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```
Check backup list
```kubectl exec -n {{ $labels.namespace }} {{ $labels.pod_name }} -c {{ $labels.container_name }} -- wget -qO- http://127.0.0.1:7171/backup/list```
Check backup commands status
```kubectl exec -n {{ $labels.namespace }} {{ $labels.pod_name }} -c {{ $labels.container_name }} -- wget -qO- http://127.0.0.1:7171/backup/status```
Run backup manually
```kubectl exec -n {{ $labels.namespace }} {{ $labels.pod_name }} -c {{ $labels.container_name }} -- clickhouse-backup create [-t, --tables=<db>.<table>] [--diff-from=<backup_name>] [--delete] <backup_name>```
- alert: ClickHouseBackupTooLong
# duration in nanoseconds so we expect 3600 * 4 * 10^9
expr: |-
clickhouse_backup_last_backup_duration{container_name='clickhouse-backup'} > 14400000000000
or clickhouse_backup_last_create_duration{container_name='clickhouse-backup'} > 14400000000000
or clickhouse_backup_last_download_duration{container_name='clickhouse-backup'} > 14400000000000
or clickhouse_backup_last_restore_duration{container_name='clickhouse-backup'} > 14400000000000
or clickhouse_backup_last_upload_duration{container_name='clickhouse-backup'} > 14400000000000
or clickhouse_backup_last_create_remote_duration{container_name='clickhouse-backup'} > 14400000000000
or clickhouse_backup_last_restore_remote_duration{container_name='clickhouse-backup'} > 14400000000000
labels:
severity: critical
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup last backup duration was more 4 hours"
description: |-
`clickhouse_backup_last_create_remote_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_create_remote_duration{pod_name='%s',namespace='%s'} / 1000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`clickhouse_backup_last_restore_remote_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_create_remote_duration{pod_name='%s',namespace='%s'} / 1000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`clickhouse_backup_last_create_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_create_duration{pod_name='%s',namespace='%s'} / 1000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`clickhouse_backup_last_upload_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_upload_duration{pod_name='%s',namespace='%s'} / 1000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`clickhouse_backup_last_download_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_download_duration{pod_name='%s',namespace='%s'} / 1000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`clickhouse_backup_last_restore_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_restore_duration{pod_name='%s',namespace='%s'} / 1000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`clickhouse_backup_last_backup_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_backup_duration{pod_name='%s',namespace='%s'} / 1000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
Check clickhouse-backup logs
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```
- alert: ClickHouseBackupTooShort
expr: |-
(clickhouse_backup_last_backup_success{container_name='clickhouse-backup'} == 1 and clickhouse_backup_last_backup_duration{container_name='clickhouse-backup'} < clickhouse_backup_last_backup_duration{container_name='clickhouse-backup'} offset 1m * 0.70)
or (clickhouse_backup_last_create_status{container_name='clickhouse-backup'} == 1 and clickhouse_backup_last_create_duration{container_name='clickhouse-backup'} < clickhouse_backup_last_create_duration{container_name='clickhouse-backup'} offset 1m * 0.70)
or (clickhouse_backup_last_download_status{container_name='clickhouse-backup'} == 1 and clickhouse_backup_last_download_duration{container_name='clickhouse-backup'} < clickhouse_backup_last_download_duration{container_name='clickhouse-backup'} offset 1m * 0.70)
or (clickhouse_backup_last_restore_status{container_name='clickhouse-backup'} == 1 and clickhouse_backup_last_restore_duration{container_name='clickhouse-backup'} < clickhouse_backup_last_restore_duration{container_name='clickhouse-backup'} offset 1m * 0.70)
or (clickhouse_backup_last_upload_status{container_name='clickhouse-backup'} == 1 and clickhouse_backup_last_upload_duration{container_name='clickhouse-backup'} < clickhouse_backup_last_upload_duration{container_name='clickhouse-backup'} offset 1m * 0.70)
labels:
severity: warning
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup last backup duration time is 30% less than the time of the previous one"
description: |-
`clickhouse_backup_last_backup_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_backup_duration{pod_name='%s',namespace='%s'} / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_backup_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"} offset 1m` = {{ with printf "clickhouse_backup_last_backup_duration{pod_name='%s',namespace='%s'} offset 1m / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_create_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_create_duration{pod_name='%s',namespace='%s'} / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_create_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"} offset 1m` = {{ with printf "clickhouse_backup_last_create_duration{pod_name='%s',namespace='%s'} offset 1m / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_download_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_download_duration{pod_name='%s',namespace='%s'} / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_download_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"} offset 1m` = {{ with printf "clickhouse_backup_last_download_duration{pod_name='%s',namespace='%s'} offset 1m / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_restore_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_restore_duration{pod_name='%s',namespace='%s'} / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_restore_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"} offset 1m` = {{ with printf "clickhouse_backup_last_restore_duration{pod_name='%s',namespace='%s'} offset 1m / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_upload_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_upload_duration{pod_name='%s',namespace='%s'} / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
`clickhouse_backup_last_upload_duration{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"} offset 1m` = {{ with printf "clickhouse_backup_last_upload_duration{pod_name='%s',namespace='%s'} offset 1m / 60000000000 " .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | printf "%.2f" }}{{ end }} minutes
Check clickhouse-backup logs
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```
ClickHouse data size
```kubectl exec -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }}-- wget -qO- "http://127.0.0.1:8123/?query=SELECT+formatReadableSize(sum(total_bytes))+FROM+system.tables+WHERE+database!='system'"```
- alert: ClickHouseBackupSizeChanged
expr: |-
(
clickhouse_backup_last_create_status{container_name='clickhouse-backup'} == 1
and clickhouse_backup_last_backup_size_local{container_name='clickhouse-backup'} offset 1m > 0
and clickhouse_backup_last_backup_size_local{container_name='clickhouse-backup'} < clickhouse_backup_last_backup_size_local{container_name='clickhouse-backup'} offset 1m * 0.60
) or (
clickhouse_backup_last_create_status{container_name='clickhouse-backup'} == 1
and clickhouse_backup_last_backup_size_local{container_name='clickhouse-backup'} offset 1m > 0
and clickhouse_backup_last_backup_size_local{container_name='clickhouse-backup'} > clickhouse_backup_last_backup_size_local{container_name='clickhouse-backup'} offset 1m * 1.40)
or (
clickhouse_backup_last_upload_status{container_name='clickhouse-backup'} == 1
and clickhouse_backup_last_backup_size_remote{container_name='clickhouse-backup'} offset 1m > 0
and clickhouse_backup_last_backup_size_remote{container_name='clickhouse-backup'} < clickhouse_backup_last_backup_size_remote{container_name='clickhouse-backup'} offset 1m * 0.60
)
or (
clickhouse_backup_last_upload_status{container_name='clickhouse-backup'} == 1
and clickhouse_backup_last_backup_size_remote{container_name='clickhouse-backup'} offset 1m > 0
and clickhouse_backup_last_backup_size_remote{container_name='clickhouse-backup'} > clickhouse_backup_last_backup_size_remote{container_name='clickhouse-backup'} offset 1m * 1.40
)
labels:
severity: warning
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup last backup size is changed more than 40% than the size of the previous one"
description: |-
`clickhouse_backup_last_backup_size_local{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_backup_size_local{pod_name='%s',namespace='%s',container_name='clickhouse-backup'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanize1024 }}B{{ end }}
`clickhouse_backup_last_backup_size_local{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"} offset 1m` = {{ with printf "clickhouse_backup_last_backup_size_local{pod_name='%s',namespace='%s',container_name='clickhouse-backup'} offset 1m" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanize1024 }}B{{ end }}
`clickhouse_backup_last_backup_size_remote{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_backup_size_local{pod_name='%s',namespace='%s',container_name='clickhouse-backup'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanize1024 }}B{{ end }}
`clickhouse_backup_last_backup_size_remote{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"} offset 1m` = {{ with printf "clickhouse_backup_last_backup_size_local{pod_name='%s',namespace='%s',container_name='clickhouse-backup'} offset 1m" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanize1024 }}B{{ end }}
Check clickhouse-backup logs
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```
ClickHouse data size
```kubectl exec -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }}-- wget -qO- "http://127.0.0.1:8123/?query=SELECT+formatReadableSize(sum(total_bytes))+FROM+system.tables+WHERE+database!='system'"```
- alert: ClickHouseRemoteBackupSizeZero
for: "36h"
expr: clickhouse_backup_last_backup_size_remote{container_name='clickhouse-backup'} == 0
labels:
severity: warning
team: ClickHouse
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup last backup size is zero last 36 hours"
description: |-
`clickhouse_backup_last_backup_size_remote{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_backup_size_remote{pod_name='%s',namespace='%s',container_name='clickhouse-backup'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanize1024 }}B{{ end }}
`clickhouse_backup_last_backup_size_local{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_last_backup_size_local{pod_name='%s',namespace='%s',container_name='clickhouse-backup'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanize1024 }}B{{ end }}
Check clickhouse-backup logs
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```
ClickHouse data size
```kubectl exec -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }}-- wget -qO- "http://127.0.0.1:8123/?query=SELECT+formatReadableSize(sum(total_bytes))+FROM+system.tables+WHERE+database!='system'"```
- alert: ClickhouseBackupDoesntRunTooLong
expr: |-
(clickhouse_backup_last_backup_end{container_name='clickhouse-backup'} > 0 and time() - clickhouse_backup_last_backup_end{container_name='clickhouse-backup'} > 129600)
or (clickhouse_backup_last_create_finish{container_name='clickhouse-backup'} > 0 and time() - clickhouse_backup_last_create_finish{container_name='clickhouse-backup'} > 129600)
or (clickhouse_backup_last_upload_finish{container_name='clickhouse-backup'} > 0 and time() - clickhouse_backup_last_upload_finish{container_name='clickhouse-backup'} > 129600)
labels:
severity: warning
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup didn't run last 24h"
description: |-
`time() - clickhouse_backup_last_backup_end{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "time() - clickhouse_backup_last_backup_end{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`time() - clickhouse_backup_last_create_finish{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "time() - clickhouse_backup_last_create_finish{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
`time() - clickhouse_backup_last_backup_finish{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "time() - clickhouse_backup_last_backup_finish{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value | humanizeDuration }}{{ end }}
Check clickhouse-backup logs
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=48h```
# https://github.com/Altinity/clickhouse-backup/issues/836
- alert: ClickHouseBackupLocalBackupUnexpectedPresent
expr: |-
in_progress_commands == 0 and (
(clickhouse_backup_number_backups_expected == -1 and clickhouse_backup_number_backups_local > 0)
or
(clickhouse_backup_number_backups_expected > 0 and clickhouse_backup_number_backups_local > clickhouse_backup_number_backups_expected)
)
for: "4h"
annotations:
identifier: "{{ $labels.pod_name }}"
summary: "clickhouse-backup have unexpected local backup"
description: |-
unexpected local backups could allocate additional disk space
`clickhouse_backup_number_backups_local{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_number_backups_local{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value }}{{ end }}
`clickhouse_backup_number_backups_local_expected{pod_name="{{ $labels.pod_name }}",namespace="{{ $labels.namespace }}"}` = {{ with printf "clickhouse_backup_number_backups_local_expected{pod_name='%s',namespace='%s'}" .Labels.pod_name .Labels.namespace | query }}{{ . | first | value }}{{ end }}
Check clickhouse-backup logs and remove local backup if necessary
```kubectl logs -n {{ $labels.namespace }} pods/{{ $labels.pod_name }} -c {{ $labels.container_name }} --since=24h```