Promethus-day5-配置文件详解+AlertManager微信邮件告警配置
发布日期:2021-05-10 01:01:23 浏览次数:33 分类:精选文章

本文共 4800 字,大约阅读时间需要 16 分钟。

AlertManager���������������������������


AlertManager������������

1.������

AlertManager���Prometheus������������������������������������������������������Prometheus������������ AlertManager���������������������������������������������������������������������������

2.������������������

���������AlertManager������������������������������������������������������������������

1���������������

  • ���������������������������������������������������������������������

2���������������

  • ���������������PromQL������������������������������������������������������
  • Prometheus���������������������������������������������������������������������������������AlertManager���

3���������������

  • AlertManager������������������������������������������������������������������

AlertManager������

1.������

  • ������������������������������������������������������������������������������������
  • ��������������������������������������������������������������������������������������� AlertManager���������������������������������������������������������������������

2.������

  • ������������������������������������������������������������������������
  • ������������������AlertManager������������������������������������

3.������

  • ���������������������������������������������������������
  • ������������������AlertManager���������������������

������������

1.���������������

1���������Alert-Manager

  • Alert-Manager���������������������������������������������������������������
  • ������������������������cat > alert-manager-main.yaml
  • ���������������������kubectl apply -f alert-manager-main.yaml
  • ���������������������kubectl get pod -n monitoring

2���������Ingress

  • ������Ingress���������������
  • ������Ingress���������������cat > alert-manager-svc.yaml
  • ���������������������kubectl apply -f alert-manager-svc.yaml

2.���������������

1������������������

-���������������������wget https://github.com/prometheus/alertmanager/releases/download/v0.21.0/alertmanager-0.21.0.linux-amd64.tar.gz

2���������������

  • ���������������mkdir alertmanager
  • ������������������������tar xf alertmanager-0.21.0.linux-amd64.tar.gz -C /prometheus/alertmanager

3���������������

  • ���������������chown -R prometheus.prometheus /prometheus

4���������������������

  • ���������������������������vim /etc/profile.d/prometheus.sh

5������������������

  • ������systemd���������������vim /usr/lib/systemd/system/prometheus-alertmanager.service
  • ������������������������������������systemctl start prometheus-alertmanager.service
  • ���������������������������������systemctl enable prometheus-alertmanager.service

������������������+������

1.������������

  • ���������������������
    global:
    resolve_timeout: 1h

2.������������������

  • ���������������������
    receivers:
    - name: team-ops-mails
    email_configs:
    - to: dukuan@xxx.com
  • ���������������������������/etc/alertmanager/config/default.html

3.������������������

  • ���������������������
    wechat_api_url: 'https://qyapi.weixin.qq.com/cgi-bin/'
    wechat_api_secret: 'JJ'
    wechat_api_corp_id: 'ww'
  • ������������������������
    - name: wechat
    wechat_configs:
    - send_resolved: true
    corp_id: 'ww'
    api_secret: 'JJ'
    to_party: '2'
    to_user: ''
    agent_id: '1000002'

4.������������������

  • ���������������������������
    {{ .Alerts.Firing | len }}������

    ���������������{{ .Labels.alertname }}

    ���������������{{ .StartsAt Format "2006-01-02 15:04:05" }}

    ���������������{{ .Annotations.description }}


Prometheus������������������

1.������������

  • Prometheus���������������������������������������
    global:
    scrape_interval: 15s # ������������������
    evaluation_interval: 15s # ������������������������
    scrape_timeout: 10s # ������������������������
    alerting:
    alertmanagers:
    - static_configs:
    - targets: ['127.0.0.1:9093']
    scrape_configs:
    - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']

2.������������

  • ������������������������������������relabel_configs���metric_relabel_configs���
    relabel_configs:
    - action: replace
    source_labels: ['job']
    regex: (.*) # ������������������������
    replacement: $1
    target_label: new_job

3.������������

  • ������protool���������������������������
    protool check config prometheus.yml

������������������

1.������������

  • ������Prometheus���
    prometheus --config.file="/usr/local/prometheus/prometheus.yml" --web.listen-address="0.0.0.0:9090" --storage.tsdb.path="/data/prometheus" --web.enable-lifecycle

2.������������������

  • ���������������������
    --config.file path  # ������������������
    --web.listen-address address # ������������
    --storage.tsdb.path path # ������������������
    --collector.systemd # ������systemd������

���������������AlertManager���������������������������������������������������������������������Prometheus���������������

上一篇:Redis-day1-介绍与安装
下一篇:Promethus-day4-监控不携带metrics接口的服务

发表评论

最新留言

很好
[***.229.124.182]2025年04月16日 09时25分22秒