DevOps Pokročilý
Prometheus Operator a kube-prometheus-stack¶
PrometheusKubernetesMonitoringOperator 6 min čtení
Prometheus Operator pro Kubernetes monitoring. ServiceMonitor, PrometheusRule a Alertmanager konfigurace.
Instalace¶
helm repo add prometheus-community \
https://prometheus-community.github.io/helm-charts
helm install monitoring prometheus-community/kube-prometheus-stack \
--namespace monitoring --create-namespace
ServiceMonitor¶
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: api-server
labels:
release: monitoring
spec:
selector:
matchLabels:
app: api-server
endpoints:
- port: metrics
interval: 15s
path: /metrics
namespaceSelector:
matchNames: [production]
PrometheusRule¶
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: api-alerts
spec:
groups:
- name: api.rules
rules:
- alert: HighErrorRate
expr: |
sum(rate(http_requests_total{status=~"5.."}[5m]))
/ sum(rate(http_requests_total[5m])) > 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "API error rate > 5%"
Alertmanager¶
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: team-notifications
spec:
route:
groupBy: [alertname, namespace]
groupWait: 30s
receiver: slack-critical
receivers:
- name: slack-critical
slackConfigs:
- channel: '#sre-alerts'
apiURL:
name: slack-webhook
key: url
Shrnutí¶
Prometheus Operator s ServiceMonitor a PrometheusRule CRDs je standard pro K8s monitoring.
Potřebujete pomoct s implementací?¶
Náš tým má zkušenosti s návrhem a implementací moderních architektur. Rádi vám pomůžeme.