إتاحة المقاييس باستخدام Actuator وPrometheus
اعرضوا صحة البوابة ومقاييس المسارات عبر Spring Boot Actuator، واجمعوها باستخدام Prometheus لتحقيق قابلية رصد كاملة.
إتاحة المقاييس باستخدام Actuator وPrometheus درس مجاني في API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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/7) وفتح باقي دورة 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/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)؟
لا تُشترط خبرة سابقة. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «إتاحة المقاييس باستخدام Actuator وPrometheus»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) هذا؟
نعم. كل درس في API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- المصادقة والتفويض باستخدام JWT
- التتبّع الموزّع باستخدام Sleuth وZipkin
- الإعداد المركزي باستخدام Config Server
- إتاحة المقاييس باستخدام Actuator وPrometheus