简体   繁体   English

Kubernetes(K8s)-在一段时间内未创建新容器时,从Prometheus / Grafana获取警报

[英]Kubernetes (K8s) - Get alert from Prometheus/Grafana when a new container is not created with a period of time

I have a system in which a container is created every hour and I want to get an alert when a container is not created for a certain period of time from Prometheus or Grafana. 我有一个每小时创建一个容器的系统,当某个时间段内未从Prometheus或Grafana创建容器时,我想得到一个警报。 Is there anyway to get a count of containers created in last let say X-hr and send an alert if the count of containers are less? 无论如何,有没有要获得最后创建的容器数量(例如X-hr),如果容器数量较少,则发送警报? The containers have a name template like : 2019-month-date-hour 容器具有一个名称模板,例如:2019-month-date-hour
Eg: 2019-5-11-23 例如:2019-5-11-23

I tried to use this query to get the count of containers created in a month count(count(container_last_seen{container_name=~"2019-5.*", namespace=$namespace}) by (container_name)) but not able to set grafana alert on this query for a period of time. 我试图使用此查询来获取由(container_name)创建的容器count(count(container_last_seen{container_name=~"2019-5.*", namespace=$namespace}) by (container_name))但是无法设置grafana对该查询发出警报一段时间。

This is what you should do 这是你应该做的

  1. use event exporter to capture the events generated in kubernetes cluster 使用事件导出器捕获kubernetes集群中生成的事件
  2. get those events in promethues 使这些事件陷入困境
  3. create prometheus rule to check for container/pod creation event 创建prometheus规则以检查容器/吊舱创建事件
  4. get prometheus invoke alert via alert manager using the rule 使用规则通过警报管理器获取普罗米修斯调用警报

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可视化 K8S CPU 资源 Prometheus 和 Grafana - Visualizing K8S CPU resources Prometheus and Grafana 普罗米修斯警报管理器不发送警报 k8s - Prometheus alert manager doesnt send alert k8s Kubernetes中的Ansible AWX RabbitMQ容器无法从具有nxdomain的k8s中获取节点 - Ansible AWX RabbitMQ container in Kubernetes Failed to get nodes from k8s with nxdomain 为 k8s 集群 pod CPU 使用情况创建 Grafana 警报 - Create Grafana Alert for k8s cluster pods CPU usage 使用k8s服务时Grafana在kubernetes集群上不起作用 - Grafana is not working on kubernetes cluster while using k8s Service 如何从 K8s 中获取 Kube.netes 集群名称 API - How to get Kubernetes cluster name from K8s API 如何从 Kubernetes k8s pod 获取堆转储? - How to get a heap dump from Kubernetes k8s pod? 普罗米修斯(k8s)(指标) - Prometheus in k8s (metrics) 如何配置中央 Prometheus/grafana 来监控/抓取多个 k8s 集群 - How to configure central Prometheus/grafana to monitor/scrape several k8s clusters 如何访问在 Azure 中运行的托管 k8s 上的 ingress-nginx 命名空间中安装的 Prometheus 和 Grafana? - How to access Prometheus and Grafana installed in the ingress-nginx namespace on managed k8s running in Azure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM