question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apply splitting to Azure Monitor metrics query with Azure.Monitor.Query

See original GitHub issue

Library name and version

Azure.Monitor.Query 1.1.0

Query/Question

Is it possible to do splitting with Azure.Monitor.Query SDK when retrieving Monitor metrics?

I’m trying to retrieve metrics for a service bus account, split by EntityName. This is possible in the portal:

image

This is the code that I have. I can retrieve the metrics but don’t know how to apply the splitting.

var credential = new ClientSecretCredential(_tenantId, _clientId, _clientSecret);
var metricsClient = new MetricsQueryClient(credential);
var resourceId = $"/subscriptions/{_subscriptionId}/resourceGroups/{_resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{_serviceBusName}";
var metrics = new[] { "ScheduledMessages", "ActiveMessages" };

var options = new MetricsQueryOptions();
options.Aggregations.Add(MetricAggregationType.Total);
options.TimeRange = TimeSpan.FromHours(4);

var result = await metricsClient.QueryResourceAsync(resourceId, metrics, options);

Environment

IDE: Visual Studio 17.5.3.

dotnet --info results:

.NET SDK:
 Version:   7.0.202
 Commit:    6c74320bc3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.202\

Host:
  Version:      7.0.5
  Architecture: x64
  Commit:       8042d61b17

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ToddKingMSFTcommented, May 3, 2023

Good point this should be better documented. Splitting and filtering actually both use the same filter parameter the only difference is splitting is where the filter value is equal to *. So an example of splitting is:

$filter=ApiName eq '*'

An example of filtering is:

$filter=ApiName eq 'GetBlob'
1reaction
scottaddiecommented, May 4, 2023

I’ll get this documented in our README file

Read more comments on GitHub >

github_iconTop Results From Across the Web

Metrics in Azure Monitor
Learn about metrics in Azure Monitor, which are lightweight monitoring data capable of supporting near real-time scenarios.
Read more >
Advanced features of Metrics Explorer - Azure Monitor
Apply splitting · Above the chart, select Apply splitting. · Choose dimensions on which to segment your chart: · Choose a limit on...
Read more >
Azure Monitor Query client library for .NET
The Azure Monitor Query client library is used to execute read-only ... Handle metrics query response; Query metrics with options; Split a ...
Read more >
Get started with metrics explorer - Azure Monitor
Learn how to create your first metric chart with Azure Monitor metrics explorer. ... Apply dimension filters and splitting.
Read more >
Azure Monitor metrics aggregation and display explained
When we apply splitting, we can see the underlying data, but it's a bit of a mess. Turns out there are 20 VMs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found