public interface Metrics extends Feature
Diffusion servers provide metrics which are made available in several ways:-
There are two types of metric collector: Session Metric Collectors and Topic Metric Collectors.
For full details regarding the configuration and operation of metric collectors see the user manual.
These can be configured to record metric data for a subset of all sessions, specified with a session filter.
The set of metrics recorded by each session metric collector is the same as those recorded for the whole server. For full details of session metrics, see the table in user manual.
If the session filters of two different session metric collectors select the same session, both will record metrics for that session. It is only valid to add the metrics of different session metric collectors if their session filters select distinct sets of sessions.
You can optionally group the sessions within a collector by session properties.
These can be configured to record metric data for a subset of all topics, specified with a topic selector.
You can optionally group the topics within a collector by topic type.
The set of metrics recorded by each topic metric collector is the same as those recorded for the whole server. For full details of topic metrics, see the table in the user manual.
If the topic selectors of two different topic metric collectors select the same topic, both will record metrics for that topic. It is only valid to add the metrics of different topic metric collectors if their topic selectors select distinct sets of topics.
The following access control restrictions are applied:
put
or
remove
a session metric collector, a
session needs the CONTROL_SERVER
global permission.
put
or
remove
a topic metric collector, a
session needs the CONTROL_SERVER
global permission.
session metric collectors
or
topic metric collectors
, a session needs
the VIEW_SERVER
global permission.
Metrics.MetricsRequest.fetch()
, session needs the
VIEW_SERVER
global permission.
This feature may be obtained from a session
as follows:
Metrics metrics = session.feature(Metrics.class);
Modifier and Type | Interface and Description |
---|---|
static interface |
Metrics.Builder<B extends Metrics.Builder<B>>
Common interface for metric collector builders.
|
static interface |
Metrics.MetricCollector
The common base interface for metric collectors.
|
static interface |
Metrics.MetricSample
Represents a single metric sample.
|
static interface |
Metrics.MetricSampleCollection
Represents a collection of metric samples.
|
static interface |
Metrics.MetricsRequest
A parameterized query that can be used to fetch metrics from the server.
|
static interface |
Metrics.MetricsResult
The result of a fetch metrics operation, initiated by a
Metrics.MetricsRequest . |
static class |
Metrics.MetricType
Enumeration defining the metric types available.
|
static interface |
Metrics.SessionMetricCollector
The definition of a session metric collector.
|
static interface |
Metrics.TopicMetricCollector
The definition of a topic metric collector.
|
Modifier and Type | Method and Description |
---|---|
CompletableFuture<List<Metrics.SessionMetricCollector>> |
listSessionMetricCollectors()
Retrieves the current session metric collectors.
|
CompletableFuture<List<Metrics.TopicMetricCollector>> |
listTopicMetricCollectors()
Retrieves the current topic metric collectors.
|
Metrics.MetricsRequest |
metricsRequest()
Creates an unconfigured
Metrics.MetricsRequest . |
CompletableFuture<?> |
putSessionMetricCollector(Metrics.SessionMetricCollector collector)
Add a session metric collector, replacing any with the same name.
|
CompletableFuture<?> |
putTopicMetricCollector(Metrics.TopicMetricCollector collector)
Add a topic metric collector, replacing any with the same name.
|
CompletableFuture<?> |
removeSessionMetricCollector(String name)
Removes any session metric collector with the given name, if it exists.
|
CompletableFuture<?> |
removeTopicMetricCollector(String name)
Removes any topic metric collector with the given name, if it exists.
|
getSession
CompletableFuture<?> putSessionMetricCollector(Metrics.SessionMetricCollector collector)
collector
- the session metric collectorIf the task completes successfully, the CompletableFuture result will be null. The result type is any rather than Void to provide forward compatibility with future iterations of this API that may provide a non-null result with a more specific result type.
Otherwise, the CompletableFuture will complete exceptionally with
a CompletionException
. Common reasons for failure, listed
by the exception reported as the
cause
, include:
InvalidFilterException
– if the metric
collector session filter is invalid;
PermissionsException
– if the calling
session does not have CONTROL_SERVER
permission;
ClusterRoutingException
– if the operation
failed due to a transient cluster error;
SessionClosedException
– if the session is
closed.
CompletableFuture<List<Metrics.SessionMetricCollector>> listSessionMetricCollectors()
If the task completes successfully, the CompletableFuture result will be a list of current session metric collectors.
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 VIEW_SERVER
permission;
SessionClosedException
– if the session is
closed.
CompletableFuture<?> removeSessionMetricCollector(String name)
name
- the session metric collector nameIf the task completes successfully, the CompletableFuture result will be null. The result type is any rather than Void to provide forward compatibility with future iterations of this API that may provide a non-null result with a more specific result type.
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 CONTROL_SERVER
permission;
ClusterRoutingException
– if the operation
failed due to a transient cluster error;
SessionClosedException
– if the session is
closed.
CompletableFuture<?> putTopicMetricCollector(Metrics.TopicMetricCollector collector)
A Metrics.TopicMetricCollector
instance can be created using
newTopicMetricCollectorBuilder
.
collector
- the topic metric collectorIf the task completes successfully, the CompletableFuture result will be null. The result type is any rather than Void to provide forward compatibility with future iterations of this API that may provide a non-null result with a more specific result type.
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 CONTROL_SERVER
permission;
ClusterRoutingException
– if the operation
failed due to a transient cluster error;
SessionClosedException
– if the session is
closed.
CompletableFuture<List<Metrics.TopicMetricCollector>> listTopicMetricCollectors()
If the task completes successfully, the CompletableFuture result will be a list of current topic metric collectors.
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 VIEW_SERVER
permission;
SessionClosedException
– if the session is
closed.
CompletableFuture<?> removeTopicMetricCollector(String name)
name
- the topic metric collector nameIf the task completes successfully, the CompletableFuture result will be null. The result type is any rather than Void to provide forward compatibility with future iterations of this API that may provide a non-null result with a more specific result type.
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 CONTROL_SERVER
permission;
ClusterRoutingException
– if the operation
failed due to a transient cluster error;
SessionClosedException
– if the session is
closed.
Metrics.MetricsRequest metricsRequest()
Metrics.MetricsRequest
. The request can be invoked using
Metrics.MetricsRequest.fetch()
to retrieve metrics for the server or cluster.
See Metrics.MetricsRequest
for more information.
Metrics.MetricsRequest
Copyright © 2024 DiffusionData Ltd. All Rights Reserved.