0
votes

I use Microsoft.Azure.Management.Fluent SDK package for accessing Azure Monitor metrics like this:

var credentials = SdkContext.AzureCredentialsFactory
    .FromServicePrincipal("some-client-id", "some-client-secret", "some-tenant-id", AzureEnvironment.AzureGlobalCloud);

var azure = Microsoft.Azure.Management.Fluent.Azure
   .Configure()
   .Authenticate(credentials)
   .WithSubscription("my-subscription");

foreach (var metricDefinition in azure.MetricDefinitions.ListByResource("my-resource-uri"))
{
    ...
}

It works fine for common metrics (Application Insights standard metrics). But how can I get my custom events with this SDK to render them in my custom app dashboard? I see recorded events in Application Insights dashboard under "Log-based metrics", but ListByResource method doesn't return them.

1

1 Answers

0
votes

I suspect this may be a bug.

The method ListByResource has 2 parameters, the 2nd one is metricnamespace.

By default, the metricnamespace is microsoft.insights/components, which is used for Application Insights standard metrics.

For Log-based metrics, the metricnamespace should be microsoft.insights/components/kusto(to check the value, you can use tools like Fiddler or developer tool of any browser). As per my test, when use ListByResource("resourceId","microsoft.insights/components/kusto"), it throws a "bad request" error. So I raised an issue to track this.