ActuatorとPrometheusによるメトリクス公開
Spring Boot Actuatorを通じてゲートウェイのヘルス情報とルートメトリクスを公開し、Prometheusで収集して可観測性を確保します。
「ActuatorとPrometheusによるメトリクス公開」はCoddyKit上の無料API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)レッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはAPI Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)コースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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,gatewayThe 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/routesMicrometer 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: trueThe 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/prometheusConfiguring 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_countspring_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/actuatorQuick 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.
よくある質問
「ActuatorとPrometheusによるメトリクス公開」レッスンは無料ですか?
はい。「ActuatorとPrometheusによるメトリクス公開」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)コースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)コースには全4レッスンが含まれています。
「ActuatorとPrometheusによるメトリクス公開」で何を学びますか?
Spring Boot Actuatorを通じてゲートウェイのヘルス情報とルートメトリクスを公開し、Prometheusで収集して可観測性を確保します。 ブラウザで直接実行するハンズオンコードでAPI Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)を演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)を始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのAPI Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)は初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「ActuatorとPrometheusによるメトリクス公開」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このAPI Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)レッスンでコードを書いて実行できますか?
はい。すべてのAPI Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)レッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- JWT認証と認可
- Sleuth/Zipkinによる分散トレーシング
- Config Serverによる集中設定管理
- ActuatorとPrometheusによるメトリクス公開