60.Cloud/80.Kubernetes
[Prometheus] kube-prometheus-stack Rule 추가 (Prometheus- Opertaor)
왕영주
2021. 2. 4. 13:49
Helm Chart 설치 시 사용했던 values 파일을 이용하여 Rule을 설정한다.
root@master01:~/kube-prometheus-stack# vim /root/kube-prometheus-stack/values.yaml
annotation을 추가해보려했으나 값이 없다고 에러가 발생한다. 아직 지원을 하지 않는 것인지 내가 못하는 것인지는 모르겠다.
additionalPrometheusRulesMap:
rule-name:
groups:
- name: testRule
rules:
- alert: test-alert-1
expr: up{service="p1-grafana"} == 1
for : 1m
- alert: test-alert-2
expr: up{service="p1-grafana"} == 0
for: 1m
labels:
severity: critical
이후 Helm Release를 Upgrade한다.
root@master01:~/kube-prometheus-stack# helm upgrade -n prometheus -f values.yaml p1 prometheus-community/kube-prometheus-stack
Release "p1" has been upgraded. Happy Helming!
NAME: p1
LAST DEPLOYED: Thu Feb 4 13:40:48 2021
NAMESPACE: prometheus
STATUS: deployed
REVISION: 12
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
kubectl --namespace prometheus get pods -l "release=p1"
Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
추가된 내역 확인
expr 에 따라 'test-alert-1' rule은 에러를 발생하고 있음을 볼 수 있다.
AlertManager에서도 아래와 같이 확인 가능하다.
다음 포스팅에서는 이 Alert를 Slack 및 E-mail로 전송하는 것을 해보려한다.
반응형