Prometheus on Kubernetes cannot edit rules configmap
Quote from moshe on 13/04/2022, 4:56 pmProblem
User wants to change ( add / edit /delete ) the configmap rules for promethues alerts
running the following command
kubectl edit configmap prometheus-kube-prometheus-stack-prometheus-rulefiles-0
allows you to see the alert rules but not to change them. any changes return to default
Solution
Starting from version 0.21 there are promethuesrule object you need to change
to see all the rules available
kubectl -n <NAMESPACE> get prometheusrule
to edit a rule
kubectl edit prometheusrule kube-prometheus-stack-general.rules
this will reflect to the configmap
scale down and up the deployment
kubectl scale deployment kube-prometheus-stack-operator –replicas=0
kubectl scale deployment kube-prometheus-stack-operator –replicas=1
Problem
User wants to change ( add / edit /delete ) the configmap rules for promethues alerts
running the following command
kubectl edit configmap prometheus-kube-prometheus-stack-prometheus-rulefiles-0
allows you to see the alert rules but not to change them. any changes return to default
Solution
Starting from version 0.21 there are promethuesrule object you need to change
to see all the rules available
kubectl -n <NAMESPACE> get prometheusrule
to edit a rule
kubectl edit prometheusrule kube-prometheus-stack-general.rules
this will reflect to the configmap
scale down and up the deployment
kubectl scale deployment kube-prometheus-stack-operator –replicas=0
kubectl scale deployment kube-prometheus-stack-operator –replicas=1
Uploaded files: