Interface Metrics.MetricsRequest

Enclosing interface:
Metrics

public static interface Metrics.MetricsRequest
A parameterized query that can be used to fetch metrics from the server.

A new request can be created with Metrics.metricsRequest()}. Requests are immutable. The server(String), currentServer() and filter(Set) methods can be used to create a configured request that either limits the metrics to a specific server or filters the metrics returned.

By default, the request will fetch metrics from all servers and will not filter the metrics.

The metrics are the same as those exposed by the Prometheus endpoint when requesting metrics in the OpenMetrics format.

Since:
6.10
  • Method Details

    • filter

      Metrics.MetricsRequest filter(Set<String> filters)
      Allows specifying a set of filters to limit the metrics returned.

      The filter may not be null. If the filter is empty then all metrics are returned.

      The filter is a set of strings. The filter matches a String if the String equals any member of the filter.

      Metrics are included only if:

      Only the last filter set by either this method or filter(Pattern) will be applied.
      Parameters:
      filters - the set of filters to use
      Returns:
      a new request derived from this fetch request but with the specified filters
    • filter

      Allows specifying a regular expression to filter the metrics returned.

      The filter may not be null.

      Similarly to filter(Set), metrics are included only if:

      Only the last filter set by either this method or filter(Set) will be applied.
      Parameters:
      filter - a regular expression to use to filter the metrics
      Returns:
      a new request derived from this fetch request but with the specified filter
    • server

      Specifies the name of the server to fetch metrics from. This is the configured server name.
      Parameters:
      server - the name of the server to fetch metrics from
      Returns:
      a new request derived from this fetch request but with the specified server
    • currentServer

      Metrics.MetricsRequest currentServer()
      Specifies that metrics should be fetched from the server to which the current session is connected.
      Returns:
      a new request derived from this fetch request but which will collect metrics from the current server
    • fetch

      Fetches the metrics from the server.

      If the fetch operation completes successfully, the CompletableFuture result will contain a Metrics.MetricsResult that can be used to access the metrics.

      Otherwise, the CompletableFuture will complete exceptionally with a CompletionException. Common reasons for failure, listed by the exception reported as the cause, include:

      If all metrics for a server are filtered out then the result will still contain an empty entry for that server.

      If either server(String) or currentServer() has been called then the result will contain an entry for that server only. Otherwise, it will contain an entry for each server in the cluster.

      Returns:
      a CompletableFuture that will complete with the metrics