MetricsQueryAsyncClient Class
- java.
lang. Object - com.
azure. monitor. query. MetricsQueryAsyncClient
- com.
public final class MetricsQueryAsyncClient
The asynchronous client for querying Azure Monitor metrics.
Instantiating an asynchronous Metrics query Client
MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder()
.credential(tokenCredential)
.buildAsyncClient();
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
Paged |
listMetricDefinitions(String resourceUri)
Lists all the metrics definitions created for the resource URI. |
|
Paged |
listMetricDefinitions(String resourceUri, String metricsNamespace)
Lists all the metrics definitions created for the resource URI. |
|
Paged |
listMetricNamespaces(String resourceUri, OffsetDateTime startTime)
Lists all the metrics namespaces created for the resource URI. |
|
Mono<Metrics |
queryResource(String resourceUri, List<String> metricsNames)
Returns all the Azure Monitor metrics requested for the resource. |
|
Mono<Response<Metrics |
queryResourceWithResponse(String resourceUri, List<String> metricsNames, MetricsQueryOptions options)
Returns all the Azure Monitor metrics requested for the resource. |
Methods inherited from java.lang.Object
Method Details
listMetricDefinitions
public PagedFlux<MetricDefinition> listMetricDefinitions(String resourceUri)
Lists all the metrics definitions created for the resource URI.
Parameters:
Returns:
listMetricDefinitions
public PagedFlux<MetricDefinition> listMetricDefinitions(String resourceUri, String metricsNamespace)
Lists all the metrics definitions created for the resource URI.
Parameters:
Returns:
listMetricNamespaces
public PagedFlux<MetricNamespace> listMetricNamespaces(String resourceUri, OffsetDateTime startTime)
Lists all the metrics namespaces created for the resource URI.
Parameters:
Returns:
queryResource
public Mono<MetricsQueryResult> queryResource(String resourceUri, List<String> metricsNames)
Returns all the Azure Monitor metrics requested for the resource.
Query metrics for an Azure resource
Mono<MetricsQueryResult> response = metricsQueryAsyncClient
.queryResource("{resource-id}", Arrays.asList("{metric-1}", "{metric-2}"));
response.subscribe(result -> {
for (MetricResult metricResult : result.getMetrics()) {
System.out.println("Metric name " + metricResult.getMetricName());
metricResult.getTimeSeries().stream()
.flatMap(timeSeriesElement -> timeSeriesElement.getValues().stream())
.forEach(metricValue ->
System.out.println("Time stamp: " + metricValue.getTimeStamp() + "; Total: "
+ metricValue.getTotal()));
}
});
Parameters:
Returns:
queryResourceWithResponse
public Mono<Response<MetricsQueryResult>> queryResourceWithResponse(String resourceUri, List<String> metricsNames, MetricsQueryOptions options)
Returns all the Azure Monitor metrics requested for the resource.
Parameters:
Returns: