Spring Boot Actuator ile İzleme
Uygulamanızı üretim ortamında izlemek, yönetmek ve incelemek için Spring Boot Actuator uç noktalarından yararlanın.
Spring Boot Actuator ile İzleme, CoddyKit'te ücretsiz bir Spring Boot 4 Complete Guide dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Spring Boot 4 Complete Guide öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Spring Boot 4 Complete Guide kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Meet Spring Boot Actuator
Spring Boot Actuator is a powerful tool that helps you monitor and manage your application when it's running in production. Think of it as your app's built-in dashboard!
It provides production-ready features without requiring you to write much code.
- Monitoring: Check health, metrics, and environment details.
- Management: Log levels, shutdown, refresh context.
- Insight: Understand your app's internal workings.
Include Actuator in Your Project
To use Actuator, you just need to add its starter dependency to your project. This brings in all the necessary libraries.
For Maven, add this to your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>Discover Actuator's Endpoints
Once Actuator is added, your application automatically exposes several "endpoints". These are HTTP URLs that provide specific information about your running app.
Some default endpoints include:
/actuator/health: Shows application health status./actuator/info: Displays general application information./actuator/metrics: Provides detailed metrics (CPU, memory, etc.).
By default, only /health and /info are exposed via web.
Run & Access Actuator
Let's create a simple Spring Boot app with Actuator. After running it, you can access the default endpoints in your browser or with a tool like curl.
Try running this and then navigate to http://localhost:8080/actuator/health.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ActuatorDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ActuatorDemoApplication.class, args);
}
}Deep Dive: The /health Endpoint
The /actuator/health endpoint is crucial for understanding your application's operational status. It aggregates information from various "health indicators".
- DiskSpace: Checks available disk space.
- DataSource: Verifies database connectivity (if configured).
- Liveness/Readiness: For Kubernetes deployments (newer versions).
It typically returns {"status": "UP"} if everything is fine, or details if something is down.
Custom Info with /info
The /actuator/info endpoint provides general information about your application. By default, it's empty, but you can easily populate it with useful details.
Add custom properties to your application.properties or application.yml:
info.app.name=MyActuatorApp
info.app.version=1.0.0
info.app.description=A demo for CoddyKitConfigure & Expose More Endpoints
By default, only /health and /info are exposed over the web. You can expose more endpoints like /beans (list all Spring beans) or /env (environment properties).
To expose all endpoints, add this to application.properties:
management.endpoints.web.exposure.include=*Monitor Performance with /metrics
The /actuator/metrics endpoint is invaluable for performance monitoring. It exposes various metrics about your application, JVM, and system.
Examples of metrics:
jvm.memory.used: Current JVM memory usage.system.cpu.usage: System CPU load.http.server.requests: Details about incoming HTTP requests.
You can query specific metrics like /actuator/metrics/jvm.memory.used for detailed data.
Build Your Own Health Checks
You can create custom health indicators to check the status of specific parts of your application, like an external service dependency or a custom cache.
Implement the HealthIndicator interface:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;
@SpringBootApplication
public class CustomHealthApp {
public static void main(String[] args) {
SpringApplication.run(CustomHealthApp.class, args);
}
}
@Component
class MyCustomHealthIndicator implements HealthIndicator {
@Override
public Health health() {
// Simulate checking an external service
boolean serviceIsUp = Math.random() > 0.5; // Randomly up or down
if (serviceIsUp) {
return Health.up().withDetail("myServiceStatus", "OK").build();
} else {
return Health.down().withDetail("myServiceStatus", "Failed").build();
}
}
}Quick Check: Actuator Endpoints
Which of the following Actuator endpoints are exposed by default over the web in a basic Spring Boot application with the Actuator dependency?
Actuator: Your App's Best Friend
Congratulations! You've learned how Spring Boot Actuator transforms your application into a production-ready, observable service.
- It provides crucial insights into your app's health and performance.
- You can easily add it with a single dependency.
- Default endpoints like
/healthand/infoare automatically available. - You can expose more endpoints and even create custom health checks.
Actuator is a must-have for any serious Spring Boot application!
Sıkça Sorulan Sorular
“Spring Boot Actuator ile İzleme” dersi ücretsiz mi?
Evet — “Spring Boot Actuator ile İzleme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Spring Boot 4 Complete Guide kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Spring Boot 4 Complete Guide kursu toplamda 4 dersten oluşur.
“Spring Boot Actuator ile İzleme” dersinde ne öğreneceğim?
Uygulamanızı üretim ortamında izlemek, yönetmek ve incelemek için Spring Boot Actuator uç noktalarından yararlanın. Spring Boot 4 Complete Guide ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Spring Boot 4 Complete Guide öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Spring Boot 4 Complete Guide, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.
“Spring Boot Actuator ile İzleme” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Spring Boot 4 Complete Guide dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Spring Boot 4 Complete Guide dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Spring Boot Uygulamalarını Docker ile Konteynerleştirme
- Spring Boot Actuator ile İzleme
- Buluta Dağıtım Stratejileri
- Spring Boot için CI/CD İşlem Hatları Oluşturma