Azure ApplicationInsights 指标语法? - 内部服务器故障

Azure ApplicationInsights Metrics Syntax? - InternalServerFault

我正在使用 ApplicationInsights API Explorer 来测试过滤器子句。但它会导致错误。

我发现了语法 (startswith(request/name, 'GET')) 的罕见示例,我从中导出了过滤器。

在 API 浏览器上: https://dev.applicationinsights.io/apiexplorer/metrics 我输入了我的帐户凭据。

我的参数是:

指标 ID:

    requests/count

过滤器:

    startswith(request/cloud_RoleInstance, 'development')

在 Kusto 语言中,查询应该是:

requests
| where cloud_RoleInstance startswith "development" 
| count 

并且工作正常:结果:~ 47,000

我的查询结果是:

  "error": {
    "message": "Unexpected error occurred",
    "code": "InternalServerFault",
    "innererror": {
      "code": "QueryCompilationError"
    }

但我预计到达 AppInsights 的请求数来自任何以 "development" 开头的 cloud_RoleInstance。

文档链接通常指向 https://dev.applicationinsights.io/ 但我似乎无法找到有关过滤器语法的任何有用信息。 属性 cloud_RoleInstance 不受支持吗?

According to the specs, the filter query is an OData query"where the keys of each clause should be applicable dimensions for the metric you are retrieving"。如果我将您的过滤器查询稍微更改为 cloud_RoleInstance eq 'development',那么我会得到一个更有用的错误:"The following dimensions are not valid in the filter clause for this metric: cloud_RoleInstance"。我会联系产品团队,以便在第一时间返回更有用的错误消息。

执行此操作的正确方法是查询 API。您可以对 Kusto 查询进行编码并按原样发送,而不是将您的查询转换为 OData。

requests
| where cloud_RoleInstance startswith "development" 
| count 

编码为:

GET /v1/apps/{YOUR_APP}/query?query=requests%7C%20where%20cloud_RoleInstance%20startswith%20%22development%22%20%7C%20count%20 

并且 returns 您正在寻找的结果。