Erweiterte Überwachung und Observability für Consul Connect Service Mesh in Kubernetes


Bicycle

Erweiterte Überwachung und Observability für Consul Connect Service Mesh in Kubernetes

In unserem vorherigen Artikel über Sichere Kommunikation in Kubernetes mit Consul Connect und Vault Agent Injector haben wir eine robuste Service-Mesh-Grundlage geschaffen. Jetzt bringen wir es auf die nächste Stufe, indem wir umfassende Überwachung und Observability für Ihr Consul Connect Service Mesh in Kubernetes implementieren.

Die Überwachung eines Service Mesh ist entscheidend für das Verständnis der Service-Performance, die Identifizierung von Engpässen, die Fehlerbehebung und die Gewährleistung der gesamten Systemgesundheit. In diesem Blog-Artikel werden wir untersuchen, wie Sie einen kompletten Observability-Stack implementieren, einschließlich Metriken-Sammlung mit Prometheus, Visualisierung mit Grafana und Distributed Tracing mit Jaeger für Ihre Consul Connect-fähigen Kubernetes-Anwendungen.

Voraussetzungen: Dieser Artikel baut auf unserem vorherigen Consul Connect und Vault Agent Injector Setup auf. Stellen Sie sicher, dass Sie das Setup aus Sichere Kommunikation in Kubernetes mit Consul Connect und Vault Agent Injector abgeschlossen haben, bevor Sie fortfahren.

Die drei Säulen der Observability im Service Mesh

1. Metriken (Prometheus + Grafana)

  • Service-Level-Metriken: Request-Raten, Response-Zeiten, Fehlerquoten
  • Infrastruktur-Metriken: CPU, Speicher, Netzwerknutzung
  • Proxy-Metriken: Envoy-Sidecar-Performance und Verbindungsstatistiken
  • Consul-Metriken: Service-Mesh-Gesundheit und Konfigurationsänderungen

2. Logs (Zentralisierte Protokollierung)

  • Anwendungs-Logs: Geschäftslogik und anwendungsspezifische Ereignisse
  • Proxy-Logs: Access-Logs, Error-Logs von Envoy-Sidecars
  • Consul Connect Logs: Service-Registrierung, Zertifikat-Rotation, Intentions

3. Traces (Distributed Tracing)

  • Request-Flow: Verfolgung von Requests über mehrere Services
  • Performance-Engpässe: Identifikation langsamer Services und Operationen
  • Fehler-Propagation: Verständnis, wie Fehler durch das Mesh kaskadieren

Architektur-Übersicht

Unser Observability-Stack integriert sich nahtlos mit Consul Connect, um umfassendes Monitoring, Metriken-Sammlung und Distributed Tracing über Ihr Service Mesh hinweg zu bieten:

Consul Connect Observability Architecture

Die Architektur besteht aus vier Kernkomponenten, die zusammenarbeiten, um vollständige Observability zu gewährleisten:

  • Anwendungen mit Envoy Sidecars: Ihre Services laufen neben Envoy-Proxies, die die Service-Mesh-Kommunikation handhaben und detaillierte Metriken und Traces ausgeben
  • Consul Connect Mesh: Stellt Service Discovery, Zertifikatsverwaltung bereit und koordiniert die Service-Mesh-Infrastruktur
  • Prometheus: Sammelt und speichert Metriken sowohl von Anwendungen als auch von Envoy Sidecars, mit automatischer Service Discovery über Consul
  • Jaeger: Erfasst Distributed Traces, um Anfragen zu verfolgen, während sie durch mehrere Services fließen
  • Grafana: Erstellt einheitliche Dashboards, die Metriken von Prometheus und Traces von Jaeger für umfassende Sichtbarkeit kombinieren

Schritt 1: Consul Connect für Observability konfigurieren

Zuerst erweitern wir unser bestehendes Consul Connect Setup, um umfassende Metriken-Sammlung zu ermöglichen.

Erweiterte Consul Values Konfiguration

Aktualisieren Sie Ihre consul-values.yaml, um Metriken und Tracing zu aktivieren:

 1# consul-values-observability.yaml
 2global:
 3  name: consul
 4  datacenter: dc1
 5  consulAPITimeout: 5s
 6  # Aktiviere Metriken-Sammlung
 7  metrics:
 8    enabled: true
 9    enableAgentMetrics: true
10    agentMetricsRetentionTime: "1m"
11
12server:
13  enabled: false
14
15client:
16  enabled: false
17
18connectInject:
19  enabled: true
20  default: false
21  consulNode:
22    meta:
23      pod-name: ${HOSTNAME}
24      node-name: ${NODE_NAME}
25  k8sAllowNamespaces: ["*"]
26  k8sDenyNamespaces: []
27
28  # Aktiviere Metriken und Tracing für Connect Proxies
29  metrics:
30    defaultEnabled: true
31    defaultEnableMerging: true
32    enableGatewayMetrics: true
33
34  # Konfiguriere Envoy Proxy Einstellungen für Observability
35  envoyExtraArgs: |
36    --log-level info
37    --component-log-level upstream:debug,connection:info
38
39  # Aktiviere Tracing
40  centralConfig:
41    enabled: true
42    defaultProtocol: "http"
43    proxyDefaults: |
44      {
45        "config": {
46          "envoy_tracing_json": {
47            "http": {
48              "name": "envoy.tracers.zipkin",
49              "typedConfig": {
50                "@type": "type.googleapis.com/envoy.extensions.tracers.zipkin.v3.ZipkinConfig",
51                "collector_cluster": "jaeger-collector",
52                "collector_endpoint_version": "HTTP_JSON",
53                "collector_endpoint": "/api/v1/spans",
54                "shared_span_context": false
55              }
56            }
57          }
58        }
59      }
60
61controller:
62  enabled: true
63
64ui:
65  enabled: false
66
67dns:
68  enabled: false
69
70externalServers:
71  enabled: true
72  hosts: ["consul.example.com"]
73  httpsPort: 8501
74  useSystemRoots: true
75
76# Aktiviere Prometheus Metriken-Scraping
77prometheus:
78  enabled: true

Consul Connect mit Observability upgraden

1# Upgrade Consul Connect mit Observability Features
2helm upgrade consul hashicorp/consul \
3  --namespace consul \
4  --values consul-values-observability.yaml
5
6# Verify the upgrade
7kubectl rollout status deployment/consul-connect-injector -n consul

Schritt 2: Prometheus Stack deployen

Deployen Sie Prometheus mit dem offiziellen kube-prometheus-stack für umfassende Kubernetes- und Service-Mesh-Überwachung.

  1# Füge Prometheus Community Helm Repository hinzu
  2helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
  3helm repo update
  4
  5# Erstelle Monitoring Namespace
  6kubectl create namespace monitoring
  7
  8# Erstelle Prometheus Values für Consul Connect Integration
  9cat > prometheus-values.yaml <<EOF
 10# Prometheus Konfiguration für Consul Connect Monitoring
 11prometheus:
 12  prometheusSpec:
 13    # Aktiviere Service Mesh Scraping
 14    additionalScrapeConfigs:
 15    - job_name: 'consul-connect-envoy-sidecar'
 16      kubernetes_sd_configs:
 17      - role: pod
 18        namespaces:
 19          names: ['demo', 'default']
 20      relabel_configs:
 21      - source_labels: [__meta_kubernetes_pod_container_name]
 22        regex: consul-connect-envoy-sidecar
 23        action: keep
 24      - source_labels: [__meta_kubernetes_pod_annotation_consul_hashicorp_com_connect_inject]
 25        regex: 'true'
 26        action: keep
 27      - source_labels: [__address__]
 28        regex: '([^:]+):.*'
 29        target_label: __address__
 30        replacement: '${1}:19000'  # Envoy Admin Port
 31      - source_labels: [__meta_kubernetes_pod_name]
 32        target_label: instance
 33      - source_labels: [__meta_kubernetes_namespace]
 34        target_label: namespace
 35      metrics_path: '/stats/prometheus'
 36
 37    - job_name: 'consul-external-servers'
 38      static_configs:
 39      - targets: ['consul.example.com:8500']
 40      metrics_path: '/v1/agent/metrics'
 41      params:
 42        format: ['prometheus']
 43
 44    # Storage Konfiguration
 45    storageSpec:
 46      volumeClaimTemplate:
 47        spec:
 48          storageClassName: standard
 49          accessModes: ["ReadWriteOnce"]
 50          resources:
 51            requests:
 52              storage: 50Gi
 53
 54    # Resource Konfiguration
 55    resources:
 56      requests:
 57        cpu: 500m
 58        memory: 2Gi
 59      limits:
 60        cpu: 1000m
 61        memory: 4Gi
 62
 63# Grafana Konfiguration
 64grafana:
 65  enabled: true
 66  adminPassword: "admin123"  # In Produktion ändern
 67  persistence:
 68    enabled: true
 69    size: 10Gi
 70  resources:
 71    requests:
 72      cpu: 250m
 73      memory: 512Mi
 74    limits:
 75      cpu: 500m
 76      memory: 1Gi
 77
 78  # Vorkonfigurierte Consul Connect Dashboards
 79  dashboardProviders:
 80    dashboardproviders.yaml:
 81      apiVersion: 1
 82      providers:
 83      - name: 'consul-connect'
 84        orgId: 1
 85        folder: 'Consul Connect'
 86        type: file
 87        disableDeletion: false
 88        editable: true
 89        options:
 90          path: /var/lib/grafana/dashboards/consul-connect
 91
 92  dashboardsConfigMaps:
 93    consul-connect: consul-connect-dashboards
 94
 95# Node Exporter für Infrastruktur-Metriken
 96nodeExporter:
 97  enabled: true
 98
 99# Alert Manager für Benachrichtigungen
100alertmanager:
101  enabled: true
102  alertmanagerSpec:
103    resources:
104      requests:
105        cpu: 100m
106        memory: 128Mi
107      limits:
108        cpu: 200m
109        memory: 256Mi
110EOF
111
112# Installiere Prometheus Stack
113helm install prometheus-stack prometheus-community/kube-prometheus-stack \
114  --namespace monitoring \
115  --values prometheus-values.yaml
116
117# Warte auf Deployment
118kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=prometheus -n monitoring --timeout=300s

Schritt 3: Jaeger für Distributed Tracing deployen

Deployen Sie Jaeger, um Distributed Traces von Ihrem Service Mesh zu erfassen und zu analysieren.

 1# Füge Jaeger Helm Repository hinzu
 2helm repo add jaegertracing https://jaegertracing.github.io/helm-charts
 3helm repo update
 4
 5# Erstelle Jaeger Values für Consul Connect Integration
 6cat > jaeger-values.yaml <<EOF
 7# Jaeger Konfiguration für Consul Connect Tracing
 8provisionDataStore:
 9  cassandra: false
10  elasticsearch: true
11
12storage:
13  type: elasticsearch
14  elasticsearch:
15    host: jaeger-elasticsearch-master
16    port: 9200
17
18agent:
19  enabled: true
20  daemonset:
21    useHostNetwork: true
22
23collector:
24  enabled: true
25  replicaCount: 2
26  service:
27    type: ClusterIP
28    # Expose Zipkin kompatiblen Endpoint für Envoy
29    zipkin:
30      port: 9411
31  resources:
32    requests:
33      cpu: 250m
34      memory: 512Mi
35    limits:
36      cpu: 500m
37      memory: 1Gi
38
39query:
40  enabled: true
41  replicaCount: 1
42  service:
43    type: ClusterIP
44  resources:
45    requests:
46      cpu: 250m
47      memory: 512Mi
48    limits:
49      cpu: 500m
50      memory: 1Gi
51
52# Konfiguriere Ingress für Jaeger UI
53ingress:
54  enabled: true
55  hosts:
56  - jaeger.local
57  annotations:
58    nginx.ingress.kubernetes.io/rewrite-target: /
59
60# Elasticsearch für Trace Storage
61elasticsearch:
62  enabled: true
63  replicas: 1
64  minimumMasterNodes: 1
65  resources:
66    requests:
67      cpu: 500m
68      memory: 2Gi
69    limits:
70      cpu: 1000m
71      memory: 4Gi
72  volumeClaimTemplate:
73    storageClassName: standard
74    accessModes: [ "ReadWriteOnce" ]
75    resources:
76      requests:
77        storage: 30Gi
78EOF
79
80# Installiere Jaeger
81helm install jaeger jaegertracing/jaeger \
82  --namespace monitoring \
83  --values jaeger-values.yaml
84
85# Warte auf Jaeger Komponenten
86kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=jaeger -n monitoring --timeout=300s

Schritt 4: Grafana Dashboards erstellen

Erstellen Sie umfassende Grafana Dashboards für Consul Connect Monitoring.

  1# Erstelle ConfigMap mit Consul Connect Dashboards
  2kubectl create configmap consul-connect-dashboards -n monitoring --from-literal=consul-connect-overview.json='
  3{
  4  "dashboard": {
  5    "id": null,
  6    "title": "Consul Connect Service Mesh Übersicht",
  7    "tags": ["consul", "service-mesh"],
  8    "timezone": "browser",
  9    "panels": [
 10      {
 11        "title": "Service Mesh Request Rate",
 12        "type": "graph",
 13        "targets": [
 14          {
 15            "expr": "sum(rate(envoy_http_downstream_rq_total[5m])) by (service)",
 16            "legendFormat": "{{service}}"
 17          }
 18        ],
 19        "yAxes": [
 20          {
 21            "label": "Requests/sek"
 22          }
 23        ]
 24      },
 25      {
 26        "title": "Service Mesh Fehlerrate",
 27        "type": "graph",
 28        "targets": [
 29          {
 30            "expr": "sum(rate(envoy_http_downstream_rq_xx{envoy_response_code_class=\"5\"}[5m])) by (service) / sum(rate(envoy_http_downstream_rq_total[5m])) by (service)",
 31            "legendFormat": "{{service}} 5xx Fehler"
 32          }
 33        ]
 34      },
 35      {
 36        "title": "Service Mesh Response Zeiten",
 37        "type": "graph",
 38        "targets": [
 39          {
 40            "expr": "histogram_quantile(0.99, sum(rate(envoy_http_downstream_rq_time_bucket[5m])) by (service, le))",
 41            "legendFormat": "{{service}} p99"
 42          },
 43          {
 44            "expr": "histogram_quantile(0.95, sum(rate(envoy_http_downstream_rq_time_bucket[5m])) by (service, le))",
 45            "legendFormat": "{{service}} p95"
 46          }
 47        ]
 48      },
 49      {
 50        "title": "Aktive Verbindungen",
 51        "type": "graph",
 52        "targets": [
 53          {
 54            "expr": "sum(envoy_http_downstream_cx_active) by (service)",
 55            "legendFormat": "{{service}}"
 56          }
 57        ]
 58      },
 59      {
 60        "title": "Consul Service Gesundheit",
 61        "type": "stat",
 62        "targets": [
 63          {
 64            "expr": "sum(consul_catalog_service_count)",
 65            "legendFormat": "Gesamte Services"
 66          },
 67          {
 68            "expr": "sum(consul_health_node_failure)",
 69            "legendFormat": "Fehlgeschlagene Nodes"
 70          }
 71        ]
 72      }
 73    ],
 74    "refresh": "30s",
 75    "time": {
 76      "from": "now-1h",
 77      "to": "now"
 78    }
 79  }
 80}'
 81
 82# Erstelle Service-spezifisches Dashboard
 83kubectl create configmap consul-connect-service-details -n monitoring --from-literal=service-details.json='
 84{
 85  "dashboard": {
 86    "title": "Consul Connect Service Details",
 87    "panels": [
 88      {
 89        "title": "Request Volume nach Service",
 90        "type": "graph",
 91        "targets": [
 92          {
 93            "expr": "sum(rate(envoy_http_downstream_rq_total[5m])) by (envoy_http_conn_manager_prefix)",
 94            "legendFormat": "{{envoy_http_conn_manager_prefix}}"
 95          }
 96        ]
 97      },
 98      {
 99        "title": "Upstream Verbindungsstatus",
100        "type": "graph",
101        "targets": [
102          {
103            "expr": "envoy_cluster_upstream_cx_active",
104            "legendFormat": "Aktiv - {{envoy_cluster_name}}"
105          },
106          {
107            "expr": "envoy_cluster_upstream_cx_connect_fail",
108            "legendFormat": "Fehlgeschlagen - {{envoy_cluster_name}}"
109          }
110        ]
111      },
112      {
113        "title": "Zertifikat-Ablauf",
114        "type": "graph",
115        "targets": [
116          {
117            "expr": "envoy_server_days_until_first_cert_expiring",
118            "legendFormat": "Tage bis Zertifikat-Ablauf"
119          }
120        ]
121      }
122    ]
123  }
124}'

Schritt 5: Erweiterte Anwendungskonfiguration mit Observability

Aktualisieren Sie Ihre Anwendungen, um den Observability-Stack vollständig zu nutzen.

Erweiterte Dynamic App mit Tracing und Metriken

  1# dynamic-app-observability.yaml
  2apiVersion: apps/v1
  3kind: Deployment
  4metadata:
  5  name: dynamic-app
  6  namespace: demo
  7  labels:
  8    app: dynamic-app
  9    version: v1.0.0
 10spec:
 11  replicas: 2
 12  selector:
 13    matchLabels:
 14      app: dynamic-app
 15  template:
 16    metadata:
 17      labels:
 18        app: dynamic-app
 19        version: v1.0.0
 20      annotations:
 21        # Consul Connect Annotationen
 22        "consul.hashicorp.com/connect-inject": "true"
 23        "consul.hashicorp.com/connect-service": "dynamic-app"
 24        "consul.hashicorp.com/connect-service-port": "8080"
 25        "consul.hashicorp.com/connect-service-upstreams": "mysql-server:3306"
 26
 27        # Aktiviere Metriken-Scraping
 28        "consul.hashicorp.com/service-metrics-enabled": "true"
 29        "consul.hashicorp.com/service-metrics-path": "/metrics"
 30        "consul.hashicorp.com/service-metrics-port": "8080"
 31
 32        # Prometheus Annotationen für Anwendungs-Metriken
 33        "prometheus.io/scrape": "true"
 34        "prometheus.io/port": "8080"
 35        "prometheus.io/path": "/metrics"
 36
 37        # Vault Agent Injector Annotationen
 38        "vault.hashicorp.com/agent-inject": "true"
 39        "vault.hashicorp.com/agent-inject-status": "update"
 40        "vault.hashicorp.com/agent-inject-vault-addr": "https://vault.example.com:8200"
 41        "vault.hashicorp.com/role": "dynamic-app-consul"
 42        "vault.hashicorp.com/agent-inject-secret-config.ini": "dynamic-app/db/creds/app"
 43        "vault.hashicorp.com/agent-inject-template-config.ini": |
 44          [DEFAULT]
 45          LogLevel = DEBUG
 46          Port = 8080
 47
 48          [DATABASE]
 49          Address = 127.0.0.1
 50          Port = 3306
 51          Database = my_app
 52          {{- with secret "dynamic-app/db/creds/app" }}
 53          User = {{ .Data.username }}
 54          Password = {{ .Data.password }}
 55          {{- end }}
 56
 57          [VAULT]
 58          Enabled = True
 59          InjectToken = True
 60          Namespace =
 61          Address = https://vault.example.com:8200
 62          KeyPath = dynamic-app/transit
 63          KeyName = app
 64
 65          [OBSERVABILITY]
 66          MetricsEnabled = True
 67          TracingEnabled = True
 68          JaegerEndpoint = http://jaeger-collector.monitoring.svc.cluster.local:14268/api/traces
 69    spec:
 70      serviceAccountName: dynamic-app-consul
 71      containers:
 72      - name: dynamic-app
 73        image: ghcr.io/infralovers/nomad-vault-mysql:1.0.0
 74        ports:
 75        - containerPort: 8080
 76          name: http
 77        env:
 78        - name: CONFIG_FILE
 79          value: "/vault/secrets/config.ini"
 80        - name: VAULT_ADDR
 81          value: "https://vault.example.com:8200"
 82        # Tracing Konfiguration
 83        - name: JAEGER_ENDPOINT
 84          value: "http://jaeger-collector.monitoring.svc.cluster.local:14268/api/traces"
 85        - name: JAEGER_SERVICE_NAME
 86          value: "dynamic-app"
 87        - name: JAEGER_SAMPLER_TYPE
 88          value: "const"
 89        - name: JAEGER_SAMPLER_PARAM
 90          value: "1"
 91        resources:
 92          requests:
 93            cpu: 256m
 94            memory: 256Mi
 95          limits:
 96            cpu: 500m
 97            memory: 512Mi
 98        livenessProbe:
 99          httpGet:
100            path: /health
101            port: 8080
102          initialDelaySeconds: 60
103          periodSeconds: 10
104        readinessProbe:
105          httpGet:
106            path: /health
107            port: 8080
108          initialDelaySeconds: 30
109          periodSeconds: 5

Schritt 6: Service Monitors für Prometheus konfigurieren

Erstellen Sie ServiceMonitor-Ressourcen für automatisches Prometheus-Scraping.

 1# consul-connect-service-monitors.yaml
 2apiVersion: monitoring.coreos.com/v1
 3kind: ServiceMonitor
 4metadata:
 5  name: consul-connect-envoy-sidecars
 6  namespace: monitoring
 7  labels:
 8    app: consul-connect
 9    component: envoy-sidecar
10spec:
11  selector:
12    matchLabels:
13      service: consul-connect-proxy
14  endpoints:
15  - port: envoy-metrics
16    path: /stats/prometheus
17    interval: 30s
18    scrapeTimeout: 10s
19  namespaceSelector:
20    matchNames:
21    - demo
22    - default
23
24---
25apiVersion: monitoring.coreos.com/v1
26kind: ServiceMonitor
27metadata:
28  name: consul-external-servers
29  namespace: monitoring
30  labels:
31    app: consul
32    component: server
33spec:
34  selector:
35    matchLabels:
36      app: consul-external
37  endpoints:
38  - port: http
39    path: /v1/agent/metrics
40    params:
41      format: ["prometheus"]
42    interval: 30s
43
44---
45apiVersion: v1
46kind: Service
47metadata:
48  name: consul-external
49  namespace: monitoring
50  labels:
51    app: consul-external
52spec:
53  type: ExternalName
54  externalName: consul.example.com
55  ports:
56  - port: 8500
57    name: http

Schritt 7: Alerting Rules deployen und konfigurieren

Erstellen Sie Alerting-Regeln für proaktive Überwachung Ihres Service Mesh.

 1# consul-connect-alerts.yaml
 2apiVersion: monitoring.coreos.com/v1
 3kind: PrometheusRule
 4metadata:
 5  name: consul-connect-alerts
 6  namespace: monitoring
 7  labels:
 8    app: consul-connect
 9    component: alerting
10spec:
11  groups:
12  - name: consul-connect.rules
13    rules:
14    - alert: ConsulConnectServiceDown
15      expr: up{job="consul-connect-envoy-sidecar"} == 0
16      for: 5m
17      labels:
18        severity: critical
19      annotations:
20        summary: "Consul Connect Service ist down"
21        description: "Service {{ $labels.instance }} ist seit mehr als 5 Minuten down."
22
23    - alert: ConsulConnectHighErrorRate
24      expr: |
25        (
26          sum(rate(envoy_http_downstream_rq_xx{envoy_response_code_class="5"}[5m])) by (service) /
27          sum(rate(envoy_http_downstream_rq_total[5m])) by (service)
28        ) * 100 > 10
29      for: 5m
30      labels:
31        severity: warning
32      annotations:
33        summary: "Hohe Fehlerrate in Consul Connect Service"
34        description: "Service {{ $labels.service }} hat eine Fehlerrate von {{ $value }}% in den letzten 5 Minuten."
35
36    - alert: ConsulConnectHighLatency
37      expr: |
38        histogram_quantile(0.99,
39          sum(rate(envoy_http_downstream_rq_time_bucket[5m])) by (service, le)
40        ) > 2000
41      for: 10m
42      labels:
43        severity: warning
44      annotations:
45        summary: "Hohe Latenz in Consul Connect Service"
46        description: "Service {{ $labels.service }} hat 99. Perzentil Latenz von {{ $value }}ms."
47
48    - alert: ConsulServiceUnhealthy
49      expr: consul_catalog_service_count{state="critical"} > 0
50      for: 5m
51      labels:
52        severity: critical
53      annotations:
54        summary: "Consul Services sind ungesund"
55        description: "{{ $value }} Consul Services sind im kritischen Zustand."
56
57    - alert: ConsulConnectCertificateExpiringSoon
58      expr: envoy_server_days_until_first_cert_expiring < 7
59      for: 1h
60      labels:
61        severity: warning
62      annotations:
63        summary: "Consul Connect Zertifikat läuft bald ab"
64        description: "Zertifikat läuft in {{ $value }} Tagen ab."

Health Check Monitoring

Überwachen Sie Consul Connect Health Checks und Service-Registrierung:

 1# Erstelle Health Check Monitoring Script
 2kubectl create configmap health-check-monitor -n demo --from-literal=monitor.sh='
 3#!/bin/bash
 4while true; do
 5  echo "=== Consul Service Status ==="
 6  curl -s "https://consul.example.com:8500/v1/agent/services" | jq .
 7
 8  echo "=== Connect Proxy Status ==="
 9  curl -s localhost:19000/clusters | grep -E "(health_flags|priority|max_requests)"
10
11  echo "=== Zertifikat-Informationen ==="
12  curl -s localhost:19000/certs | jq .
13
14  sleep 30
15done'
16
17# Führe Health Monitoring aus
18kubectl run health-monitor --image=curlimages/curl:latest -n demo --rm -it --restart=Never -- sh -c "
19  apk add --no-cache jq bash
20  while true; do
21    echo '=== Service Mesh Health Check ==='
22    curl -s localhost:19000/ready && echo 'Envoy Ready' || echo 'Envoy Not Ready'
23    curl -s localhost:19000/stats | grep server.state
24    sleep 30
25  done
26"

Monitoring Best Practices

1. Wichtige zu überwachende Metriken

Service Mesh Ebene:

  • Request-Rate: rate(envoy_http_downstream_rq_total[5m])
  • Fehlerrate: rate(envoy_http_downstream_rq_xx[5m])
  • Response-Zeit: histogram_quantile(0.95, envoy_http_downstream_rq_time_bucket)
  • Verbindungsanzahl: envoy_http_downstream_cx_active

Infrastruktur-Ebene:

  • CPU- und Speichernutzung von Envoy-Sidecars
  • Netzwerk-Durchsatz
  • Zertifikat-Ablaufzeiten
  • Consul Cluster-Gesundheit

2. Alerting-Schwellenwerte

  • Fehlerrate: > 5% anhaltend für 5 Minuten
  • Response-Zeit: p95 > 1 Sekunde anhaltend für 10 Minuten
  • Verfügbarkeit: Service down für > 2 Minuten
  • Zertifikat-Ablauf: < 7 Tage verbleibend

3. Dashboard-Organisation

  • Übersichts-Dashboard: High-Level Service-Mesh-Metriken
  • Service-spezifische Dashboards: Detaillierte Metriken pro Service
  • Infrastruktur-Dashboard: Kubernetes- und Infrastruktur-Metriken
  • Sicherheits-Dashboard: mTLS-Status, Zertifikat-Gesundheit, Intention-Verletzungen

Fazit

Die Implementierung umfassender Observability für Ihr Consul Connect Service Mesh in Kubernetes bietet entscheidende Einblicke in Service-Performance, Sicherheit und Gesundheit. Mit Prometheus-Metriken, Grafana-Dashboards und Jaeger-Tracing können Sie:

  • Service-Mesh-Performance überwachen mit detaillierten Metriken und Dashboards
  • Distributed Requests verfolgen über mehrere Services mit Tracing
  • Proaktiv Probleme identifizieren durch intelligente Alerting
  • Effizient Probleme troubleshooten mit korrelierten Metriken, Logs und Traces
  • Sicherheits-Compliance gewährleisten durch Überwachung von mTLS-Zertifikaten und Intentions

Dieser Observability-Stack baut auf unserer sicheren Service-Mesh-Grundlage auf und bietet die Sichtbarkeit, die für den zuverlässigen Betrieb von Consul Connect in Produktions-Kubernetes-Umgebungen erforderlich ist.

Wichtige Erkenntnisse:

  • Drei Säulen: Metriken, Logs und Traces bieten vollständige Observability
  • Automatisierte Sammlung: ServiceMonitor-Ressourcen ermöglichen automatische Metriken-Erkennung
  • Custom Dashboards: Maßgeschneiderte Visualisierungen für Service-Mesh-spezifische Metriken
  • Proaktive Alerting: Frühwarnsystem für Service-Mesh-Probleme
  • Performance-Monitoring: Überwachung und Optimierung des Service-Mesh-Overheads
  • Sicherheits-Sichtbarkeit: Überwachung der Zertifikat-Gesundheit und Kommunikationsmuster

Beginnen Sie heute mit der Überwachung Ihres Consul Connect Service Mesh und gewinnen Sie die Einblicke, die für die Aufrechterhaltung hoher Verfügbarkeit, Performance und Sicherheit in Ihrer Kubernetes-Umgebung erforderlich sind.

Für die Implementierung von Multi-Platform Service-Mesh-Architekturen, die Kubernetes, Nomad, Bare Metal und VMs umfassen, sehen Sie unseren umfassenden Leitfaden über Multi-Platform Service Mesh: Kubernetes, Nomad, Bare Metal und VMs mit Consul Connect verbinden.

Zurück Unsere Trainings entdecken

Wir sind für Sie da

Sie interessieren sich für unsere Trainings oder haben einfach eine Frage, die beantwortet werden muss? Sie können uns jederzeit kontaktieren! Wir werden unser Bestes tun, um alle Ihre Fragen zu beantworten.

Hier kontaktieren