0Pricing
API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) · Lektion

Metriken mit Actuator & Prometheus bereitstellen

Machen Sie Gateway-Health- und Routenmetriken über Spring Boot Actuator verfügbar und erfassen Sie sie mit Prometheus für umfassende Observability.

Metriken mit Actuator & Prometheus bereitstellen ist eine kostenlose API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Seeing Inside the Gateway

Tracing shows individual request journeys, but you also need aggregate metrics: request rates, error counts, latency. Spring Boot Actuator plus Micrometer expose these for the gateway.

Adding Actuator

The Actuator starter adds production-ready endpoints for health, info, and metrics.

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Exposing Endpoints

By default most endpoints are hidden over HTTP. Expose the ones you need explicitly.

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus,gateway

The Gateway Endpoint

The gateway actuator endpoint lists all active routes and their configuration, invaluable for debugging routing in a running system.

curl http://localhost:8080/actuator/gateway/routes

Micrometer Metrics

Micrometer is the metrics facade. The gateway records timers like spring.cloud.gateway.requests tagged by route id, status, and method.

Enabling Gateway Metrics

Make sure metric collection for the gateway is turned on so per-route timers are recorded.

spring:
  cloud:
    gateway:
      metrics:
        enabled: true

The Prometheus Registry

Add the Prometheus registry so metrics are published in Prometheus' text format at /actuator/prometheus.

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

Inspecting the Scrape Endpoint

Hit the endpoint to see raw metrics. Prometheus will scrape this same URL on a schedule.

curl http://localhost:8080/actuator/prometheus

Configuring a Scrape Job

Point Prometheus at the gateway with a scrape job describing the path and target.

scrape_configs:
  - job_name: gateway
    metrics_path: /actuator/prometheus
    static_configs:
      - targets: ['gateway:8080']

Useful Metrics to Watch

Key signals include request count, error rate (5xx), and p95 latency per route. Alert when error rate or latency crosses a threshold.

  • spring_cloud_gateway_requests_seconds_count
  • spring_cloud_gateway_requests_seconds_max

Securing the Endpoints

Actuator endpoints can leak internals. In production restrict them to an internal network or protect them with authentication.

management:
  endpoints:
    web:
      base-path: /internal/actuator

Quick Check

Which actuator endpoint exposes metrics in a format Prometheus can scrape?

Recap

You made the gateway observable:

  • Actuator exposes health, metrics, and the gateway route view
  • Micrometer records per-route timers
  • The Prometheus registry serves /actuator/prometheus
  • Prometheus scrapes and you alert on errors and latency

With tracing plus metrics you have end-to-end visibility into gateway traffic.

Häufig gestellte Fragen

Ist die Lektion „Metriken mit Actuator & Prometheus bereitstellen“ kostenlos?

Ja — der vollständige Text von „Metriken mit Actuator & Prometheus bereitstellen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Metriken mit Actuator & Prometheus bereitstellen“?

Machen Sie Gateway-Health- und Routenmetriken über Spring Boot Actuator verfügbar und erfassen Sie sie mit Prometheus für umfassende Observability. Du übst API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) zu starten?

Keine Vorkenntnisse erforderlich. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Metriken mit Actuator & Prometheus bereitstellen“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)-Lektion Code schreiben und ausführen?

Ja. Jede API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. JWT-Authentifizierung und Autorisierung
  2. Verteiltes Tracing mit Sleuth und Zipkin
  3. Zentrale Konfiguration mit Config Server
  4. Metriken mit Actuator & Prometheus bereitstellen
← Zurück zu API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)