المقاييس ولوحات المعلومات باستخدام Micrometer وPrometheus
اعرض مقاييس التطبيق باستخدام Micrometer، واجمعها باستخدام Prometheus، وتصور اتجاهاتها في Grafana لتحقيق قابلية ملاحظة شاملة.
المقاييس ولوحات المعلومات باستخدام Micrometer وPrometheus درس مجاني في Spring Boot 4 Complete Guide على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Spring Boot 4 Complete Guide، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Spring Boot 4 Complete Guide 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Beyond Logs and Traces
Logs tell you what happened and traces show request paths, but metrics reveal trends over time: request rates, error percentages, memory use. They complete the observability picture.
What Is Micrometer?
Micrometer is a metrics facade, like SLF4J but for metrics. You instrument once and export to many backends such as Prometheus or Datadog.
Wiring in Prometheus
Add the Prometheus registry dependency and Actuator exposes a scrape endpoint automatically.
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>Exposing the Endpoint
Enable the Prometheus endpoint so metrics are served at /actuator/prometheus in a format Prometheus understands.
management.endpoints.web.exposure.include=health,prometheusThe Three Core Meter Types
Most metrics fall into three types.
- Counter — only goes up (requests served)
- Gauge — goes up and down (queue size)
- Timer — measures durations
Creating a Counter
Register a counter and increment it when an event occurs.
Counter c = registry.counter("orders.placed");
c.increment();Timing Code
A Timer records how long operations take, giving you latency percentiles.
Timer t = registry.timer("checkout.duration");
t.record(() -> processCheckout());Tags for Dimensionality
Add tags (labels) to slice metrics by endpoint, status, or region. Avoid high-cardinality tags like user IDs, which explode storage.
registry.counter("http.requests", "status", "200").increment();How Prometheus Scrapes
Prometheus periodically pulls the /actuator/prometheus endpoint and stores time-series data, which you can then query with PromQL.
Visualizing with Grafana
Grafana connects to Prometheus as a data source and renders dashboards. Spring Boot has ready-made dashboards for JVM and HTTP metrics.
Alerting on Metrics
Define alert rules, for example error rate above 5 percent, so the team is notified before users complain. Metrics turn into proactive operations.
Quick Check
Test your understanding of metrics and observability.
Recap
You exposed metrics via Micrometer and the Prometheus Actuator endpoint, learned counters, gauges, and timers, used tags wisely, and visualized and alerted with Prometheus and Grafana.
الأسئلة الشائعة
هل درس «المقاييس ولوحات المعلومات باستخدام Micrometer وPrometheus» مجاني؟
نعم — نص درس «المقاييس ولوحات المعلومات باستخدام Micrometer وPrometheus» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Spring Boot 4 Complete Guide، انتقل إلى CoddyKit PRO. تتضمن دورة Spring Boot 4 Complete Guide 4 دروس في المجموع.
ماذا ستتعلم في «المقاييس ولوحات المعلومات باستخدام Micrometer وPrometheus»؟
اعرض مقاييس التطبيق باستخدام Micrometer، واجمعها باستخدام Prometheus، وتصور اتجاهاتها في Grafana لتحقيق قابلية ملاحظة شاملة. تتمرن على Spring Boot 4 Complete Guide مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Spring Boot 4 Complete Guide؟
لا تُشترط خبرة سابقة. Spring Boot 4 Complete Guide على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «المقاييس ولوحات المعلومات باستخدام Micrometer وPrometheus»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Spring Boot 4 Complete Guide هذا؟
نعم. كل درس في Spring Boot 4 Complete Guide يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- أساسيات تنسيق Kubernetes
- التتبّع الموزّع باستخدام Sleuth وZipkin
- فحوصات الصحة وأنماط المرونة
- المقاييس ولوحات المعلومات باستخدام Micrometer وPrometheus