_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

Prometheus Operator a kube-prometheus-stack

03. 07. 2020 1 min read intermediate

DevOps Intermediate

Prometheus Operator a kube-prometheus-stack

PrometheusKubernetesMonitoringOperator 6 min read

Prometheus Operator pro Kubernetes monitoring. ServiceMonitor, PrometheusRule a Alertmanager konfigurace.

Installation

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

Summary

Prometheus Operator s ServiceMonitor a PrometheusRule CRDs je standard pro K8s monitoring.

Need Help with Implementation?

Our team has experience designing and implementing modern architectures. We’re happy to help.

Free Consultation

Share:

CORE SYSTEMS tým

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.