Prometheus 使用PrometheusRule定义告警规则

网友投稿 398 2022-11-02


Prometheus 使用PrometheusRule定义告警规则

[root@master prometheus-operator]# cat example-rule.yaml apiVersion: monitoring.coreos.com/v1kind: PrometheusRulemetadata: labels: prometheus: example role: alert-rules name: prometheus-example-rulesspec: groups: - name: ./example.rules rules: - alert: ExampleAlert expr: vector(1)

[root@master prometheus-operator]# kubectl apply -f example-rule.yaml -n monitoringprometheusrule.monitoring.coreos.com/prometheus-example-rules created

[root@master prometheus-operator]# kubectl get PrometheusRule -n monitoring --show-labelsNAME AGE LABELSprometheus-example-rules 2m25s prometheus=example,role=alert-rules

创建完告警规则之后,还需要去普罗米修斯里面去关联一下告警规则

[root@master prometheus-operator]# cat prometheus-inst.yamlapiVersion: monitoring.coreos.com/v1kind: Prometheusmetadata: name: k8s namespace: monitoringspec: serviceAccountName: prometheus serviceMonitorSelector: matchLabels: team: frontend ruleSelector: matchLabels: role: alert-rules prometheus: example alerting: alertmanagers: - name: alertmanager-example namespace: monitoring port: web resources: requests: memory: 400Mi


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Spring的BeanFactoryPostProcessor接口示例代码详解
下一篇:Linux ln命令 软链接和硬链接
相关文章

 发表评论

暂时没有评论,来抢沙发吧~