0%
المراقبة باستخدام Prometheus و Grafana

المراقبة باستخدام Prometheus و Grafana

مراقبة الخدمات المصغّرة

10-15 دقيقة

المراقبة باستخدام Prometheus و Grafana

في هذا الفصل، سنستعرض كيفية إنشاء نظام مراقبة متكامل باستخدام Prometheus و Grafana. وسنرى كيف نجمع مقاييس خدماتنا المصغّرة ونخزّنها ونعرضها بصريًا.

1. إعداد Prometheus

تشغيل Prometheus

docker run -d -p 9090:9090 \
  -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
  prom/prometheus

الإعداد الأساسي

# prometheus.yml
global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'spring-boot-app'
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['localhost:8080']

2. إعداد التطبيقات

الاعتماديات

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

إعداد Actuator

# application.yml
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
  endpoint:
    health:
      show-details: always
  metrics:
    tags:
      application: ${spring.application.name}
    distribution:
      percentiles-histogram:
        http.server.requests: true
      sla:
        http.server.requests: 10ms, 50ms, 100ms, 200ms, 500ms

التعليقات

التعليقات مدعومة عبر GitHub Discussions

سجّل الدخول باستخدام GitHub للمشاركة في النقاش

تم نسخ الرابط!