Table of Contents

Interface IMetricsRequest

Namespace
PushTechnology.ClientInterface.Client.Features.Metrics
Assembly
Diffusion.Client.dll

A parameterized query that can be used to fetch metrics from the server.

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.

IMetricsRequest CurrentServer { get; }

Property Value

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.

Task<IMetricsResult> FetchAsync()

Returns

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

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.

Task<IMetricsResult> FetchAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token used to cancel the current operation.

Returns

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

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.

IMetricsRequest Filter(HashSet<string> filters)

Parameters

filters HashSet<string>

The hash set of filters to use.

Returns

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:

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.

IMetricsRequest Filter(string filter)

Parameters

filter string

A regular expression to use to filter the metrics.

Returns

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:

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.

IMetricsRequest Server(string server)

Parameters

server string

The name of the server to fetch metrics from.

Returns

IMetricsRequest

A new request derived from this fetch request but with the specified server.