Interface Metrics.MetricsRequest
- Enclosing interface:
- Metrics
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 Summary
Modifier and TypeMethodDescriptionSpecifies that metrics should be fetched from the server to which the current session is connected.fetch()
Fetches the metrics from the server.Allows specifying a regular expression to filter the metrics returned.Allows specifying a set of filters to limit the metrics returned.Specifies the name of the server to fetch metrics from.
-
Method Details
-
filter
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:
-
The filter matches a
Metrics.MetricSampleCollection
name, in which case the entire collection and its samples are returned. -
The filter doesn't match a
Metrics.MetricSampleCollection
name but matches at least one of itsMetrics.MetricSample
children. In this case, theMetrics.MetricSampleCollection
is returned with only the matching childMetrics.MetricSample
s.
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
-
The filter matches a
-
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:-
The regular expression matches a
Metrics.MetricSampleCollection
name, in which case the entire collection and its samples are returned. -
The regular expression doesn't match a
Metrics.MetricSampleCollection
name but matches at least one of itsMetrics.MetricSample
children. In this case, theMetrics.MetricSampleCollection
is returned with only the matching childMetrics.MetricSample
s.
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
-
The regular expression matches a
-
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
CompletableFuture<Metrics.MetricsResult> 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 thecause
, include:PermissionsException
– if the calling session does not haveGlobalPermission.VIEW_SERVER
permission;ClusterRoutingException
– if the operation failed due to a transient cluster error;SessionClosedException
– if the session is closed.
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)
orcurrentServer()
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
-