promtheus使用技巧及运维记录(一)

韵味老鸟 2024-06-26 17:58:42

promtheus 使用技巧及运维记录(一)

Q6:匹配与不匹配

匹配

node_cpu_seconds_total{cluster="sz-dev",mode="idle"}

node_cpu_seconds_total{cluster=~"sz-dev",mode="idle"}

不匹配

node_cpu_seconds_total{cluster="sz-dev",mode="idle"}

node_cpu_seconds_total{cluster=~"sz-dev",mode="idle"}

= 与 =~ 区别

!~ 后面跟的是正则表达式,跟 =~ 正好相反

!= 就是普通的字符串比较不等于,跟 = 相反

Q5: 告警环境分组

如果匹配到告警中包含标签team,并且team的值为dev,Alertmanager将会按照标签product和environment对告警进行分组。此时如果应用出现异常,开发团队就能清楚的知道哪一个环境(environment)中的哪一个应用程序出现了问题,可以快速对应用进行问题定位

route: receiver: 'default-receiver' group_wait: 30s group_interval: 5m repeat_interval: 4h group_by: [cluster, alertname] routes: - receiver: 'dba-pager' group_wait: 10s match_re: service: mysql|pgsql - receiver: 'dev-pager' group_by: [product, environment] match: team: dev

Q4:告警触发调试

#触发web报警./amtool --alertmanager.url=http://10.10.10.22:9093 alert add department=web alertname="xxx流量告警" --annotation=description='xxx每分钟访问量超过15000' --annotation=summary = "xxx流量告警"#触发api报警./amtool --alertmanager.url=http://10.10.10.22:9093 alert add department=api alertname="xxx流量告警" --annotation=description='xxx每分钟访问量超过15000' --annotation=summary = "xxx流量告警"

0 阅读:1