我有一个运行在EKS
上的kubernetes
集群
我已经从这个repository安装了prometheus
和alertmanager
。
这是一套工具,所以我认为它对像我这样的乞丐很有用。
现在我可以通过localhost:9090
看到prometheus Jmeter 板,我的pod也在这里。
有三个alertmanager。(可能和node一样?)
$kubectl get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system aws-node-669m7 1/1 Running 0 29m
kube-system aws-node-7rwhg 1/1 Running 0 29m
kube-system aws-node-f7tnf 1/1 Running 0 39m
kube-system cluster-autoscaler-78c99d7c59-6gbn7 1/1 Running 0 31m
kube-system coredns-7dbf6bcd5b-5hgjx 1/1 Running 0 49m
kube-system coredns-7dbf6bcd5b-ff5b4 1/1 Running 0 49m
kube-system kube-proxy-jrwxh 1/1 Running 0 29m
kube-system kube-proxy-lwm9q 1/1 Running 0 39m
kube-system kube-proxy-xp9l9 1/1 Running 0 29m
monitoring alertmanager-main-0 2/2 Running 0 35m
monitoring alertmanager-main-1 2/2 Running 0 35m
monitoring alertmanager-main-2 2/2 Running 0 35m
monitoring blackbox-exporter-69f4d86566-d99bk 3/3 Running 0 36m
monitoring grafana-79cd8d4b69-2k9np 1/1 Running 0 36m
monitoring kube-state-metrics-56f8746666-q298b 3/3 Running 0 31m
monitoring node-exporter-ndln7 2/2 Running 0 29m
monitoring node-exporter-psqng 2/2 Running 0 29m
monitoring node-exporter-z92vx 2/2 Running 0 35m
monitoring prometheus-adapter-77f56b865b-4sgv7 1/1 Running 0 31m
monitoring prometheus-adapter-77f56b865b-f9tx6 1/1 Running 0 35m
monitoring prometheus-k8s-0 2/2 Running 0 35m
monitoring prometheus-k8s-1 2/2 Running 0 35m
monitoring prometheus-operator-54f6687b97-5mdbb 2/2 Running 0 35m
然后,我想做的是设置警报,当节点超过4时,它会发送电子邮件到我的Gmail帐户。
所以我做了alertmanager.yml
(这不是我的意思,这只是样本,只是练习。)
global:
resolve_timeout: 5m
smtp_from: 'prometheus.test@example.com'
smtp_smarthost: 'localhost:25'
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'web.hook'
routes:
- receiver: 'mailtest'
match:
test_type: SampleAlert
receivers:
- name: 'mailtest'
email_configs:
- to: 'root@localhost.localdomain'
require_tls: false
- name: 'web.hook'
webhook_configs:
- url: 'https://127.0.0.1:5001/'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
然后文档说,我可以将其附加为nohup ./alertmanager --config.file=alertmanager.yml &
但是,我本地PC中没有alertmanager
命令。
我应该如何将这个yml应用到运行在EKS
上的alertmanager pod?
1条答案
按热度按时间suzh9iv81#
如docs所述:您可以在您的values中添加Alert Manager配置。
values.alertmanager.config
下的yaml文件Alert manager作为secret导入到kubernetes,如果您想查看正在应用的内容,您需要运行kubectl get secrets
然后从中提取数据。要对配置进行更复杂的操作,您需要熟悉libsonnet。