Class ActuatorClient

java.lang.Object
com.nmontytskyi.monitoring.server.polling.ActuatorClient

@Component public class ActuatorClient extends Object
HTTP client for retrieving monitoring data from Spring Boot Actuator endpoints.

Sends GET requests to /actuator/health (service availability and status) and /actuator/metrics (JVM CPU, heap, thread, and GC metrics) on behalf of MetricsPollingScheduler. Connection and read timeouts are configurable via PollingProperties.

Author:
Nazar Montytskyi
See Also:
  • Constructor Details

  • Method Details

    • fetchHealth

      public Optional<HealthStatus> fetchHealth(String actuatorUrl)
    • fetchMetricValue

      public Optional<Double> fetchMetricValue(String actuatorUrl, String metricName)
    • fetchMetricValue

      public Optional<Double> fetchMetricValue(String actuatorUrl, String metricName, String tag)
      Fetches a metric filtered by a URL tag dimension (e.g. area:nonheap). Use this only for metrics where the tag is a real Micrometer tag key, not for timer statistics such as TOTAL_TIME / COUNT / MAX — use fetchTimerStatistic(java.lang.String, java.lang.String, java.lang.String) for those.
    • fetchTimerStatistic

      public Optional<Double> fetchTimerStatistic(String actuatorUrl, String metricName, String statistic)
      Fetches a Timer metric and returns the value of a specific statistic (COUNT, TOTAL_TIME, MAX). The statistic is a field inside the measurements array of the Actuator response — it is NOT a URL tag filter.

      Returns Optional.empty() when the metric does not exist yet (e.g. no GC pauses have occurred) or when the requested statistic is absent.