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

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

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

参考资料: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

相关文章:

  • 2021-06-10
  • 2022-02-03
  • 2021-09-15
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2021-09-22
猜你喜欢
  • 2021-11-22
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-10
相关资源
相似解决方案