public static interface Metrics.MetricsRequest
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.
Modifier and Type | Method and Description |
---|---|
Metrics.MetricsRequest |
currentServer()
Specifies that metrics should be fetched from the server to which the current session is connected.
|
CompletableFuture<Metrics.MetricsResult> |
fetch()
Fetches the metrics from the server.
|
Metrics.MetricsRequest |
filter(Pattern filter)
Allows specifying a regular expression to filter the metrics returned.
|
Metrics.MetricsRequest |
filter(Set<String> filters)
Allows specifying a set of filters to limit the metrics returned.
|
Metrics.MetricsRequest |
server(String server)
Specifies the name of the server to fetch metrics from.
|
Metrics.MetricsRequest filter(Set<String> filters)
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:
Metrics.MetricSampleCollection
name, in which case the entire collection
and its samples are returned.
Metrics.MetricSampleCollection
name but matches at least one of its
Metrics.MetricSample
children. In this case, the Metrics.MetricSampleCollection
is
returned with only the matching child Metrics.MetricSample
s.
filter(Pattern)
will be applied.filters
- the set of filters to useMetrics.MetricsRequest filter(Pattern filter)
The filter may not be null.
Similarly to filter(Set)
, metrics are included only if:
Metrics.MetricSampleCollection
name, in which case the
entire collection and its samples are returned.
Metrics.MetricSampleCollection
name but matches at
least one of its Metrics.MetricSample
children. In this case, the Metrics.MetricSampleCollection
is
returned with only the matching child Metrics.MetricSample
s.
filter(Set)
will be applied.filter
- a regular expression to use to filter the metricsMetrics.MetricsRequest server(String server)
server
- the name of the server to fetch metrics fromMetrics.MetricsRequest currentServer()
CompletableFuture<Metrics.MetricsResult> fetch()
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:
PermissionsException
– if the calling
session does not have GlobalPermission.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)
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.
Copyright © 2024 DiffusionData Ltd. All Rights Reserved.