Spring Boot ile Prometheus ve Grafana Dashboard Kurulumu | Monitoring Rehberi

Bu rehberde Spring Boot uygulamalarını Prometheus ve Grafana ile izlemek için gerekli tüm adımları öğreneceksiniz.

Kısa özet: Prometheus metrik toplar, Grafana görselleştirir. Spring Boot Actuator ile metrikler dışarı açılır.

Prometheus Nedir?

Prometheus, açık kaynaklı bir monitoring ve alerting sistemidir. Özellikle mikroservis mimarilerinde metrik toplamak için kullanılır.

  • Çok boyutlu veri modeli
  • Güçlü sorgu dili: PromQL
  • HTTP pull yöntemi ile veri toplama

Adım 1 — Prometheus Kurulumu (Linux)

Yanlış binary'yi kaldırıp doğru Linux sürümünü kurun:

cd /home/monitor
rm -rf prometheus-3.11.2.darwin-amd64/

wget https://github.com/prometheus/prometheus/releases/download/v3.11.2/prometheus-3.11.2.linux-amd64.tar.gz

tar -xzf prometheus-3.11.2.linux-amd64.tar.gz

cd prometheus-3.11.2.linux-amd64/
./prometheus

Kontrol için: http://localhost:9090

Not: Yanlış OS binary kullanırsanız Prometheus çalışmaz.

Adım 2 — Spring Boot Prometheus Entegrasyonu

Spring Boot monitoring için Micrometer ve Actuator kullanılır.

Maven Bağımlılıkları

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

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

application.properties

management.endpoints.web.exposure.include=health,info,prometheus

Metrikleri kontrol edin: http://localhost:8888/actuator/prometheus


Adım 3 — Prometheus Konfigürasyonu

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'spring-boot-app'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:8888']

Prometheus arayüzünde Status → Targets bölümünden kontrol edebilirsiniz.


Adım 4 — Grafana Kurulumu

sudo apt-get install -y adduser libfontconfig1 musl

wget https://dl.grafana.com/enterprise/release/grafana-enterprise_10.3.1_amd64.deb

sudo dpkg -i grafana-enterprise_10.3.1_amd64.deb
sudo apt-get install grafana

sudo service grafana-server start

Arayüz: http://localhost:3000

Bilgi: İlk girişte kullanıcı adı ve şifre admin / admin

Adım 5 — Grafana Dashboard Kurulumu

  1. Grafana → Data Sources → Prometheus ekleyin
  2. URL: http://localhost:9090
  3. Dashboard → Import
  4. ID: 11378

Sonuç

  • Prometheus ile metrik topladınız
  • Grafana ile görselleştirdiniz
  • Gerçek zamanlı monitoring sağladınız

Sık Sorulan Sorular

Prometheus ne işe yarar?

Sistem ve uygulama metriklerini toplar ve analiz eder.

Grafana ne yapar?

Prometheus verilerini grafik ve dashboard olarak görselleştirir.

Etiketler: spring boot monitoring, prometheus kurulumu, grafana dashboard, actuator metrics, devops monitoring

Latest Software Developers - Yazılım Blog Yazarı Profil Resmi

Yazar

LatestSoftwareDevelopers

Güncel yazılım teknolojilerinin takip edildiği blog.

Devops ile ilgili yorumlar

Yorum Paylaş

EMail Zorunlu alanlar * *