Skip to content

Monitoring & Health Checks

можно. provides endpoints for health checks, Prometheus metrics, and distributed tracing via Spring Boot Actuator and Micrometer.

Health Check

Endpoint

GET /actuator/health

Response:

json
{
  "status": "UP",
  "components": {
    "db": {"status": "UP"},
    "diskSpace": {"status": "UP"}
  }
}

Status codes:

  • UP — component is healthy
  • DOWN — component is unavailable

Docker Usage

yaml
healthcheck:
  test: ["CMD-SHELL", "wget -qO- http://localhost:8080/actuator/health | grep -q UP"]
  interval: 15s
  timeout: 5s
  retries: 3
  start_period: 60s

Prometheus Metrics

Endpoint

GET /actuator/prometheus

Metrics are available in Prometheus format and include:

CategoryExample Metrics
HTTP Requestshttp_server_requests_seconds_count, http_server_requests_seconds_sum
JVMjvm_memory_used_bytes, jvm_gc_pause_seconds, jvm_threads_live
HikariCPhikaricp_connections_active, hikaricp_connections_pending
Cachecache_gets_total, cache_puts_total, cache_evictions_total

Prometheus Configuration

yaml
scrape_configs:
  - job_name: 'mozhno'
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['mozhno:8080']

Key Metrics to Monitor

MetricWhat to Watch
http_server_requests_seconds_countTotal request count
http_server_requests_seconds_sum{status="5.."}Server errors
jvm_memory_used_bytes{area="heap"}Heap memory usage
hikaricp_connections_activeActive DB connections (should be < maxSize)
hikaricp_connections_pendingConnection queue (should be ~0)

Distributed Tracing

можно. uses Micrometer Tracing with Brave. Each request receives a traceId and spanId, passed in headers:

HeaderDescription
X-B3-TraceIdTrace identifier
X-B3-SpanIdSpan identifier

The traceId also appears in logs via MDC (key traceId).

Sampling probability setting:

VariableDefaultDescription
MANAGEMENT_TRACING_SAMPLING_PROBABILITY1.0Fraction of traced requests (0.0–1.0)

Logging

Log format: JSON (via Logstash Logback Encoder). Record structure:

json
{
  "@timestamp": "2026-06-21T13:41:05.123Z",
  "level": "INFO",
  "logger": "dev.mozhno.flags.FlagService",
  "message": "Flag updated: new-checkout",
  "traceId": "abc123",
  "service": "feature-flags"
}

Sensitive data (JWT, API keys, passwords) is automatically masked via SensitiveDataMasker.

Important Environment Variables

VariableDefaultDescription
LOGGING_LEVEL_DEV_MOZHNOINFOApplication log level
LOGGING_LEVEL_ROOTINFORoot log level
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDEhealth,info,metrics,prometheusList of exposed actuator endpoints
MANAGEMENT_TRACING_SAMPLING_PROBABILITY1.0Fraction of traced requests
  • Docker — healthcheck and environment variables
  • Scaling — horizontal scaling
  • Scaling — horizontal scaling
  • Metrics — flag usage metrics

Released under the AGPL v3.0 License.