���������������{{ .Labels.alertname }}
���������������{{ .StartsAt Format "2006-01-02 15:04:05" }}
���������������{{ .Annotations.description }}
本文共 4800 字,大约阅读时间需要 16 分钟。
AlertManager���Prometheus������������������������������������������������������Prometheus������������ AlertManager���������������������������������������������������������������������������
���������AlertManager������������������������������������������������������������������
cat > alert-manager-main.yaml
kubectl apply -f alert-manager-main.yaml
kubectl get pod -n monitoring
cat > alert-manager-svc.yaml
kubectl apply -f alert-manager-svc.yaml
-���������������������wget https://github.com/prometheus/alertmanager/releases/download/v0.21.0/alertmanager-0.21.0.linux-amd64.tar.gz
mkdir alertmanager
tar xf alertmanager-0.21.0.linux-amd64.tar.gz -C /prometheus/alertmanager
chown -R prometheus.prometheus /prometheus
vim /etc/profile.d/prometheus.sh
vim /usr/lib/systemd/system/prometheus-alertmanager.service
systemctl start prometheus-alertmanager.service
systemctl enable prometheus-alertmanager.service
global: resolve_timeout: 1h
receivers: - name: team-ops-mails email_configs: - to: dukuan@xxx.com
/etc/alertmanager/config/default.html
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'
{{ .Alerts.Firing | len }}������ ���������������{{ .Labels.alertname }}
���������������{{ .StartsAt Format "2006-01-02 15:04:05" }}
���������������{{ .Annotations.description }}
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']
relabel_configs
���metric_relabel_configs
��� relabel_configs: - action: replace source_labels: ['job'] regex: (.*) # ������������������������ replacement: $1 target_label: new_job
protool
��������������������������� protool check config prometheus.yml
prometheus --config.file="/usr/local/prometheus/prometheus.yml" --web.listen-address="0.0.0.0:9090" --storage.tsdb.path="/data/prometheus" --web.enable-lifecycle
--config.file path # ������������������--web.listen-address address # ������������--storage.tsdb.path path # ������������������--collector.systemd # ������systemd������
���������������AlertManager���������������������������������������������������������������������Prometheus���������������