Class PrometheusService

java.lang.Object
org.tailormap.api.prometheus.PrometheusService

@Component public class PrometheusService extends Object
Service for managing Prometheus-related operations. This service can be used to manage Prometheus-related operations such as querying and managing metrics stored in the Prometheus instance.
  • Constructor Details

    • PrometheusService

      public PrometheusService(org.springframework.web.client.RestTemplate template)
  • Method Details

    • isPrometheusAvailable

      public boolean isPrometheusAvailable()
      Check if the Prometheus server is available by sending a simple query.
    • executeQuery

      public com.fasterxml.jackson.databind.JsonNode executeQuery(String promQuery) throws com.fasterxml.jackson.core.JsonProcessingException, IOException
      Executes a Prometheus query and returns the result.
      Parameters:
      promQuery - the Prometheus query to execute
      Returns:
      the result of the query as a JSON node
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is an error processing the JSON response
      IOException - if there is an error executing the query
      See Also:
    • deleteMetric

      public void deleteMetric(String metricName) throws IOException
      Executes a Prometheus delete query.
      Parameters:
      metricName - the Prometheus metric to be deleted
      Throws:
      IOException - if there is an error executing the delete query
    • cleanTombstones

      public void cleanTombstones() throws IOException
      Executes a Prometheus tombstone query.
      Throws:
      IOException - if there is an error executing the delete query