Spring Boot 4 Microservices & REST APIs · Ders

Sağlık Göstergeleri

Uygulamanın ve bağımlılıkların sağlık durumunu bildirin.

2. ders / 413 adım

Sağlık Göstergeleri, CoddyKit'te ücretsiz bir Spring Boot 4 Microservices & REST APIs 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 Microservices & REST APIs öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Spring Boot 4 Microservices & REST APIs kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

The Health Endpoint

The /actuator/health endpoint reports whether the application and its dependencies are functioning. Load balancers and orchestrators poll it to decide if an instance should receive traffic.

GET /actuator/health
{ "status": "UP" }

Aggregated Status

Overall health is an aggregate of many health indicators. If any critical indicator reports DOWN, the overall status becomes DOWN. Statuses include UP, DOWN, and OUT_OF_SERVICE.

Built-in Indicators

Boot auto-configures indicators for common dependencies — datasource, disk space, Redis, RabbitMQ, and others — whenever the corresponding starter is present. They contribute to the aggregate automatically.

Showing Health Details

By default details are hidden. Reveal per-component breakdowns with management.endpoint.health.show-details, ideally only to authenticated callers.

management:
  endpoint:
    health:
      show-details: when-authorized
      # or: always / never

Detailed Output

With details enabled, the response lists each component’s status and contributed data, making it easy to see which dependency is failing.

{
  "status": "UP",
  "components": {
    "db": { "status": "UP", "details": { "database": "PostgreSQL" } },
    "diskSpace": { "status": "UP" }
  }
}

A Custom HealthIndicator

Implement HealthIndicator to report on a dependency Boot does not cover — say, a downstream API. Return Health.up() or Health.down() with optional details.

@Component
public class PaymentApiHealthIndicator implements HealthIndicator {
    private final PaymentClient client;
    public PaymentApiHealthIndicator(PaymentClient client) { this.client = client; }

    @Override
    public Health health() {
        return client.ping()
            ? Health.up().withDetail("latencyMs", client.lastLatency()).build()
            : Health.down().withDetail("reason", "ping failed").build();
    }
}

Indicator Naming

The component name is derived from the bean/class name with the HealthIndicator suffix stripped. PaymentApiHealthIndicator appears as paymentApi in the output.

Liveness and Readiness Probes

In Kubernetes you distinguish liveness (is the app alive?) from readiness (can it serve traffic?). Boot exposes both as health groups when probes are enabled.

management:
  endpoint:
    health:
      probes:
        enabled: true
# exposes /actuator/health/liveness and /readiness

Health Groups

Group indicators under a named subset so probes only consider the relevant checks. Readiness might include the database; liveness usually should not, to avoid pod restarts on transient outages.

management:
  endpoint:
    health:
      group:
        readiness:
          include: db,paymentApi

Tuning Status to HTTP Codes

Actuator maps health statuses to HTTP codes — UP to 200, DOWN to 503 by default — so infrastructure can act on the response code without parsing the body.

Designing Good Health Checks

Keep checks fast and meaningful:

  • Probe real dependencies, not just process liveness
  • Avoid heavy work that itself causes failures
  • Separate liveness from readiness to prevent restart storms

Quick Check

Test your understanding of custom indicators.

Recap

Health endpoints signal operational status.

  • /actuator/health aggregates many indicators
  • Built-in indicators cover common dependencies
  • Implement HealthIndicator for custom checks
  • Use show-details wisely; names strip the suffix
  • Enable liveness/readiness probes and groups for Kubernetes
Başlamak ücretsiz

Yapay zeka eğitmeniyle Java öğren — ücretsiz

Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.

Kurslar
24
Dersler
93

Sıkça Sorulan Sorular

“Sağlık Göstergeleri” dersi ücretsiz mi?

Evet — “Sağlık Göstergeleri” 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 Microservices & REST APIs kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Spring Boot 4 Microservices & REST APIs kursu toplamda 4 dersten oluşur.

“Sağlık Göstergeleri” dersinde ne öğreneceğim?

Uygulamanın ve bağımlılıkların sağlık durumunu bildirin. Spring Boot 4 Microservices & REST APIs 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 Microservices & REST APIs öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Spring Boot 4 Microservices & REST APIs, 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.

“Sağlık Göstergeleri” 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 Microservices & REST APIs dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Spring Boot 4 Microservices & REST APIs 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

  1. Actuator Uç Noktalarını Etkinleştirme
  2. Sağlık Göstergeleri
  3. Micrometer ile Özel Ölçümler
  4. Actuator Uç Noktalarını Güvenceye Alma
← Spring Boot 4 Microservices & REST APIs Sayfasına Dön