如何使用Azure Monitor SDK加载自定义事件?

问题描述 投票:0回答:1

我使用Microsoft.Azure.Management.Fluent SDK包来访问Azure Monitor指标,如下所示:

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"))
{
    ...
}

它对于常见指标(Application Insights标准指标)工作正常。但是,如何使用此SDK获取自定义事件,以将其呈现在自定义应用仪表板中?我在Application Insights仪表板的“基于日志的指标”下看到了记录的事件,但ListByResource方法未返回它们。

azure azure-application-insights azure-monitoring
1个回答
0
投票

我怀疑这可能是错误。

ListByResource方法有2个参数,第二个是metricnamespace

默认情况下,metricnamespacemicrosoft.insights/components,用于Application Insights standard metrics

对于Log-based metricsmetricnamespace应该为microsoft.insights/components/kusto(要检查该值,可以使用Fiddlerdeveloper tool of any browser之类的工具)。根据我的测试,当使用ListByResource("resourceId","microsoft.insights/components/kusto")时,它将引发“错误请求”错误。因此,我提出了an issue以对此进行跟踪。

© www.soinside.com 2019 - 2024. All rights reserved.