首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自AlertManager容器的cAdvisor通知

来自AlertManager容器的cAdvisor通知
EN

Stack Overflow用户
提问于 2021-08-19 10:16:15
回答 1查看 640关注 0票数 2

我正在使用常用的监视工具(Prometheus、cAdvisor、AlertManager),我面临的问题是,每30分钟就有一台服务器触发containerCpuUsage,但不幸的是,我不知道这是哪个容器(我猜这是cAdvisor本身,但它的cpu使用率确实很低!)所以我的第一个问题是,有没有办法告诉AlertManager --基于prometheus规则--也发送容器名称?

(cAdvisor本身比其他容器使用更多的CPU )

cadvisor-rule.yaml

代码语言:javascript
复制
- alert: ContainerCpuUsage
    expr: (sum(rate(container_cpu_usage_seconds_total[3m])) BY (instance, name) * 100) > 80
    for: 5m
    labels:
      severity: warning
    annotations:
      summary: "Container CPU usage (instance {{ $labels.instance }})"
      description: "Container CPU usage is above 80%\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"

我试过{{ $labels.name }}{{ $labels.job }},但不起作用。

因此,让我们调用实例名为A,然后在其中有一个nginx & cadvisor容器。监视工具正在另一个实例上运行,我如何将容器名称放入规则标签,或者是否有其他方法来实现它!

EN

回答 1

Stack Overflow用户

发布于 2021-10-18 12:13:17

在cAdvisor中,有时容器本身可以占用更多的CPU。

代码语言:javascript
复制
  # cAdvisor can sometimes consume a lot of CPU, so this alert will fire constantly.
  # If you want to exclude it from this alert, exclude the serie having an empty name: container_cpu_usage_seconds_total{name!=""}

在我的示例中,我使用cAdvisor启动了--name=cadvisor容器,并添加了以下规则表达式:

代码语言:javascript
复制
expr: (sum(rate(container_cpu_usage_seconds_total{name!="cadvisor"}[3m])) BY (instance, name) * 100) > 80
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68846003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档