【问题标题】:Azure ApplicationInsights Metrics Syntax? - InternalServerFaultAzure ApplicationInsights 指标语法? - 内部服务器故障
【发布时间】:2019-08-16 13:34:05
【问题描述】:

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

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

在 API Explorer 上: 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"
    }

但我希望从任何以“开发”开头的 cloud_RoleInstance 到达 AppInsights 的请求数。

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

【问题讨论】:

    标签: azure syntax azure-application-insights metrics


    【解决方案1】:

    According to the specs,过滤器查询是OData query“其中每个子句的键应该是您正在检索的指标的适用维度”。如果我将您的过滤器查询稍微更改为cloud_RoleInstance eq 'development',那么我会收到一个更有用的错误:“以下维度在此指标的过滤器子句中无效:cloud_RoleInstance”。我将与产品团队联系,以首先返回更有用的错误消息。

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

    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 
    

    并返回您要查找的结果。

    【讨论】:

    • 仅供参考,根据我的测试,如果名称包含“_”,如 cloud_RoleInstance 或 client_city,则会发生相同的错误。
    • 我用 appid 对其进行了测试并得到了相同的结果,所以不幸的是它不仅限于带有下划线的列。我怀疑关键是什么被认为是“适用的维度”,但一旦我收到产品团队的回复,我就会知道更多。
    猜你喜欢
    • 2021-11-14
    • 2018-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多