Interface IMetricsRequest
A parameterized query that can be used to fetch metrics from the server.
Namespace: PushTechnology.ClientInterface.Client.Features.Metrics
Assembly: Diffusion.Client.dll
Syntax
public interface IMetricsRequest
Remarks
A new request can be created with IMetricsRequest. Requests are immutable. The Server(String), CurrentServer and Filter(HashSet<String>) 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.
Properties
CurrentServer
Specifies that metrics should be fetched from the server to which the current session is connected.
Declaration
IMetricsRequest CurrentServer { get; }
Property Value
Type | Description |
---|---|
IMetricsRequest | A new request derived from this fetch request but which will collect metrics from the current server. |
Methods
FetchAsync()
Fetches the metrics from the server.
Declaration
Task<IMetricsResult> FetchAsync()
Returns
Type | Description |
---|---|
Task<IMetricsResult> | A Task that completes when a response is received from the server. |
Remarks
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.
If the task completes successfully, the Task result will contain a IMetricsResult that can be used to access the metrics.
Exceptions
Type | Condition |
---|---|
SessionSecurityException | If the calling session does not have VIEW_SERVER permission. Thrown by the returned task. |
ClusterRoutingException | If the operation failed due to a transient cluster error. Thrown by the returned task. |
SessionClosedException | The calling session is closed. Thrown by the returned task. |
FetchAsync(CancellationToken)
Fetches the metrics from the server.
Declaration
Task<IMetricsResult> FetchAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token used to cancel the current operation. |
Returns
Type | Description |
---|---|
Task<IMetricsResult> | A Task that completes when a response is received from the server. |
Remarks
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.
If the task completes successfully, the Task result will contain a IMetricsResult that can be used to access the metrics.
Exceptions
Type | Condition |
---|---|
SessionSecurityException | If the calling session does not have VIEW_SERVER permission. Thrown by the returned task. |
ClusterRoutingException | If the operation failed due to a transient cluster error. Thrown by the returned task. |
SessionClosedException | The calling session is closed. Thrown by the returned task. |
Filter(HashSet<String>)
Allows specifying a set of filters to limit the metrics returned.
Declaration
IMetricsRequest Filter(HashSet<string> filters)
Parameters
Type | Name | Description |
---|---|---|
HashSet<String> | filters | The hash set of filters to use. |
Returns
Type | Description |
---|---|
IMetricsRequest | A new request derived from this fetch request but with the specified filters. |
Remarks
The filter may not be null. If the filter is empty then all metrics are returned.
The filter is a hash 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 IMetricSampleCollection name, in which case the entire collection and its samples are returned.
- The filter doesn't match a IMetricSampleCollection name but matches at least one of its IMetricSample children. In this case, the IMetricSampleCollection is returned with only the matching child IMetricSamples.
Only the last filter set by either this method or Filter(String) will be applied.
Filter(String)
Allows specifying a regular expression to filter the metrics returned.
Declaration
IMetricsRequest Filter(string filter)
Parameters
Type | Name | Description |
---|---|---|
String | filter | A regular expression to use to filter the metrics. |
Returns
Type | Description |
---|---|
IMetricsRequest | A new request derived from this fetch request but with the specified filter. |
Remarks
The filter may not be null.
Similarly to Filter(HashSet<String>), metrics are included only if:
- The regular expression matches a IMetricSampleCollection name, in which case the entire collection and its samples are returned.
- The regular expression doesn't match a IMetricSampleCollection name but matches at least one of its IMetricSample children. In this case, the IMetricSampleCollection is returned with only the matching child IMetricSamples.
Only the last filter set by either this method or Filter(HashSet<String>) will be applied.
Server(String)
Specifies the name of the server to fetch metrics from. This is the configured server name.
Declaration
IMetricsRequest Server(string server)
Parameters
Type | Name | Description |
---|---|---|
String | server | The name of the server to fetch metrics from. |
Returns
Type | Description |
---|---|
IMetricsRequest | A new request derived from this fetch request but with the specified server. |