首页 > 其他 > 详细

【2020.07.07】如何自动探测到自定义的record rule

时间:2020-07-07 10:16:19      阅读:82      评论:0      收藏:0      [点我收藏+]

上一篇博客中,有说到用kube-prometheus安装prometheus全家桶,用来监控,其中演示了如何通过自定义yaml文件的形式来添加,它有点不好的地方,就是要提前在samplejson.net文件中去定义,这不利于已经搭建成功的场景。

prometheus-operator

自动探测自定义的record rule得力于prometheus-operator这个项目,你只需要自定义PrometheusRule文件,然后apply应用它,则系统会自动通过调用k8s api来获取到该资源,然后把他动态增量加载到prometheus配置中,无需重启。

技术分享图片

参考资料:https://github.com/coreos/prometheus-operator/issues/3111

自定义PrometheusRule资源清单文件

    技术分享图片
      1 apiVersion: monitoring.coreos.com/v1
      2 kind: PrometheusRule
      3 metadata:
      4   labels:
      5     prometheus: k8s
      6     role: alert-rules
      7   name: mqcountnew
      8   namespace: monitoring
      9 spec:
     10   groups:
     11   - name: mqcount1
     12     rules:
     13     - expr: rabbitmq_queue_messages{queue="test"}
     14       labels:
     15         namespace: bookstore1
     16         service: mqservice1
     17       record: enriched_rabbitmq_queue_messages1
    record_rule_auto.yaml
  • 过几分钟后验证:技术分享图片

【2020.07.07】如何自动探测到自定义的record rule

原文:https://www.cnblogs.com/eastpig/p/13258918.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!