alertmanager设置定时静默告警脚本
# 每周五6点20定时停止告警
#!/bin/bash
now_date=`date +%F`
future_date=`date +%F --date="+3 day"`
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"alertname","value":"gf_RabbitMQ_published","isRegex":false},{"name":"instance","value":"gf_RabbitMQ","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
##########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"instance","value":"gf-md_hq","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
############
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"instance","value":"quote-md_hq","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
##########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"alertname","value":"ait0_gm_stock","isRegex":false},{"name":"instance","value":"ait0-gm_hq","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
###########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"alertname","value":"ait0_gm_future","isRegex":false},{"name":"instance","value":"ait0-gm_future_hq","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"instance","value":"airm-quoteproxy_hq","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
#########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"instance","value":"airm-nano_hq","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"instance","value":"gf-md_hq_qianhai","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
##########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"instance","value":"airm-fortex_hq","isRegex":false}],"startsAt":"'${now_date}'T22:20:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
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
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
# 其它时间段停止静默告警
#!/bin/bash
now_date=`date +%F`
future_date=`date +%F --date="+1 day"`
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"alertname","value":"ait0_gm_stock","isRegex":false},{"name":"instance","value":"ait0-gm_hq","isRegex":false}],"startsAt":"'${now_date}'T07:35:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
###########
curl 'http://172.16.30.250:9093/api/v2/silences' \
-H 'Content-Type: application/json' \
--data '{"matchers":[{"name":"alertname","value":"ait0_gm_future","isRegex":false},{"name":"instance","value":"ait0-gm_future_hq","isRegex":false}],"startsAt":"'${now_date}'T07:35:00.000","endsAt":"'${future_date}'T23:00:00.000","createdBy":"jaylen","comment":"tmp","id":null}' \
--compressed --insecure
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
上次更新: 2023/06/09, 19:14:23