【问题标题】:How to use filter on cloud/roleName in Azure Application Insights?如何在 Azure Application Insights KQuery (KQL) 中对 cloud/roleName 使用过滤器
【发布时间】:2022-12-03 09:27:22
【问题描述】:

我在 Azure Application Insights 中创建了“New Failures Analysis”工作簿。在那里,我使用以下查询添加了一个自定义图表,以显示请求、失败、异常等的计数,基于云/角色名称财产。

{
  "type": 10,
  "content": {
    "chartId": "xxxxxxxxxxxxxxxxxxx",
    "version": "MetricsItem/2.0",
    "size": 3,
    "chartType": 0,
    "resourceType": "microsoft.insights/components",
    "metricScope": 0,
    "resourceIds": [
      "xxxxxxxxxxx"
    ],
    "timeContext": {
      "durationMs": 86400000
    },
    "metrics": [
      {
        "namespace": "microsoft.insights/components",
        "metric": "microsoft.insights/components--requests/count",
        "aggregation": 7
      },
      {
        "namespace": "microsoft.insights/components",
        "metric": "microsoft.insights/components--requests/failed",
        "aggregation": 7
      },
      {
        "namespace": "microsoft.insights/components",
        "metric": "microsoft.insights/components--exceptions/count",
        "aggregation": 7
      },
      {
        "namespace": "microsoft.insights/components",
        "metric": "microsoft.insights/components--requests/duration",
        "aggregation": 4
      },
      {
        "namespace": "microsoft.insights/components",
        "metric": "microsoft.insights/components--requests/rate",
        "aggregation": 4
      }
    ],
    "gridFormatType": 2,
    "filters": [
      {
        "key": "cloud/roleName",
        "operator": 0,
        "values": [
          "xxxxxxxxx"
        ]
      }
    ],
    "gridSettings": {
      "formatters": [
        {
          "columnMatch": "Subscription",
          "formatter": 5
        },
        {
          "columnMatch": "Name",
          "formatter": 5,
          "formatOptions": {
            "linkTarget": "Resource"
          }
        },
        {
          "columnMatch": "Segment",
          "formatter": 5
        },
        {
          "columnMatch": "microsoft.insights/components--requests/count",
          "formatter": 8,
          "formatOptions": {
            "min": 0,
            "max": 5000,
            "palette": "green"
          },
          "numberFormat": {
            "unit": 0,
            "options": {
              "style": "decimal"
            }
          }
        },
        {
          "columnMatch": "microsoft.insights/components--requests/count Timeline",
          "formatter": 5
        },
        {
          "columnMatch": "microsoft.insights/components--requests/failed",
          "formatter": 8,
          "formatOptions": {
            "min": 0,
            "max": 20,
            "palette": "orangeRed"
          },
          "numberFormat": {
            "unit": 0,
            "options": {
              "style": "decimal"
            }
          }
        },
        {
          "columnMatch": "microsoft.insights/components--requests/failed Timeline",
          "formatter": 5
        },
        {
          "columnMatch": "microsoft.insights/components--exceptions/count",
          "formatter": 8,
          "formatOptions": {
            "min": 0,
            "max": 20,
            "palette": "yellowOrangeRed"
          },
          "numberFormat": {
            "unit": 0,
            "options": {
              "style": "decimal"
            }
          }
        },
        {
          "columnMatch": "microsoft.insights/components--exceptions/count Timeline",
          "formatter": 5
        },
        {
          "columnMatch": "microsoft.insights/components--requests/duration",
          "formatter": 8,
          "formatOptions": {
            "min": 0,
            "max": 1000,
            "palette": "yellowGreenBlue"
          }
        },
        {
          "columnMatch": "microsoft.insights/components--requests/duration Timeline",
          "formatter": 5
        },
        {
          "columnMatch": "microsoft.insights/components--requests/rate",
          "formatter": 8,
          "formatOptions": {
            "min": 0,
            "palette": "blueGreen"
          },
          "numberFormat": {
            "unit": 31,
            "options": {
              "style": "decimal"
            }
          }
        },
        {
          "columnMatch": "microsoft.insights/components--requests/rate Timeline",
          "formatter": 5
        }
      ],
      "rowLimit": 10000,
      "labelSettings": [
        {
          "columnId": "microsoft.insights/components--requests/count",
          "label": "Requests"
        },
        {
          "columnId": "microsoft.insights/components--requests/count Timeline",
          "label": "microsoft.insights/components--requests/count (Count) Timeline"
        },
        {
          "columnId": "microsoft.insights/components--requests/failed",
          "label": "Failed"
        },
        {
          "columnId": "microsoft.insights/components--requests/failed Timeline",
          "label": "microsoft.insights/components--requests/failed (Count) Timeline"
        },
        {
          "columnId": "microsoft.insights/components--exceptions/count",
          "label": "Exceptions"
        },
        {
          "columnId": "microsoft.insights/components--exceptions/count Timeline",
          "label": "microsoft.insights/components--exceptions/count (Count) Timeline"
        },
        {
          "columnId": "microsoft.insights/components--requests/duration",
          "label": "Avg Response Time"
        },
        {
          "columnId": "microsoft.insights/components--requests/duration Timeline",
          "label": "microsoft.insights/components--requests/duration (Average) Timeline"
        },
        {
          "columnId": "microsoft.insights/components--requests/rate",
          "label": "Request Rate"
        },
        {
          "columnId": "microsoft.insights/components--requests/rate Timeline",
          "label": "microsoft.insights/components--requests/rate (Average) Timeline"
        }
      ]
    }
  },
  "name": "metric - 01"
}

上面的查询在几天前运行良好,但突然间这个查询没有给出任何结果,即使在 Azure Application Insights 中可以找到特定云/角色名称属性的日志。

【问题讨论】:

  • 查询在哪里?
  • 那里没有查询,那是工作簿指标步骤,而不是查询步骤。它使用 Azure Metrics 作为数据源,而不是 Log Analytics。话虽这么说,它应该仍然有效?

标签: azure azure-application-insights kql azure-monitor-workbooks


【解决方案1】:

指标 ID 看起来不太正确。当我在 Workbooks 中添加一个指标时,例如,失败的请求,我得到 ID "metric": "microsoft.insights/components-Failures-requests/failed" 而不是 "metric": "microsoft.insights/components--requests/failed"。我很好奇这个工作簿 JSON 是如何生成的?我会再次重新创建此指标步骤并检查问题是否仍然存在。如果是这样,还要检查您是否也没有在“指标”刀片中看到任何结果。如果工作簿之后继续显示不正确的结果,我建议提交支持请求。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-20
    • 1970-01-01
    • 1970-01-01
    • 2016-09-09
    • 2021-07-16
    • 1970-01-01
    相关资源
    最近更新 更多