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.
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
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
Adım 5 — Grafana Dashboard Kurulumu
- Grafana → Data Sources → Prometheus ekleyin
- URL:
http://localhost:9090 - Dashboard → Import
- 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.