章工运维 章工运维
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)

章工运维

业精于勤,荒于嬉
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)
  • linux

  • windows

  • 中间件

  • 网络

  • 安全

  • 存储

  • 防火墙

  • 数据库

  • 系统

  • docker

  • other

  • 监控

    • zabbix

    • prometheus

      • prometheus监控、告警与存储
      • 使用docker-compose搭建promethes+grafana监控系统
      • prometheus添加钉钉消息告警
      • alertmanager实现某个时间段静默某些告警项
      • prometheus设置表达式触发告警
      • 监控MySQL运行状态:MySQLD Exporter
      • alertmanager设置定时静默告警脚本
        • 构建高大上的黑盒监控平台
        • prometheus使用一个redis_exporter监控所有redis实例
        • alertmanager-webhook与API
    • 运维
    • 监控
    • prometheus
    章工运维
    2023-06-02
    目录

    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

    # 其它时间段停止静默告警

    #!/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
    微信 支付宝
    上次更新: 2023/06/09, 19:14:23

    ← 监控MySQL运行状态:MySQLD Exporter 构建高大上的黑盒监控平台→

    最近更新
    01
    shell脚本模块集合
    05-13
    02
    生活小技巧(认知版)
    04-29
    03
    生活小技巧(防骗版)
    04-29
    更多文章>
    Theme by Vdoing | Copyright © 2019-2025 | 点击查看十年之约 | 鄂ICP备2024072800号
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式