首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >应用程序洞察--如何引用交叉引用查询中的所有表

应用程序洞察--如何引用交叉引用查询中的所有表
EN

Stack Overflow用户
提问于 2020-08-02 14:02:13
回答 2查看 643关注 0票数 1

我有多个应用程序洞察被相关的多个API应用所引用,如下所示。API1 - AI1 (应用程序1链接到应用程序Insight 1命名为ai1)、API2 - AI2 (应用程序链接2命名为ai2)、API3 - AI3 (应用程序链接到应用程序链接3命名为ai3)等等。API1调用API2 (现在调用API3 ),我需要从交叉引用查询中的所有三个Application中提取所有信息(例如:请求、依赖项、事件等)。

代码语言:javascript
运行
复制
union     
(
app('ai1').requests
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai1').dependencies
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai2').requests
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai2').dependencies
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai3').requests
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai3').dependencies
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
)

上面的查询非常有效。您可能会注意到,查询并不精确。有没有一种方法,我可以将所有类型的表合并成一个,这样我的查询就简单而准确了,如下所示。

代码语言:javascript
运行
复制
union 
(
app('ai1').**union**
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai2').**union**
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
app('ai3').**union**
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-08-04 02:05:24

实际上,您不能将所有类型的表合并为一个表,比如使用app('ai1').**union**requestsdependencies等必须是显式指定的。如果我误解了你,请纠正我。

您可以使用以下查询:

代码语言:javascript
运行
复制
union 
(
 union app("ai1").requests, app("ai1").dependencies
 | where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
 union app("ai2").requests, app("ai2").dependencies
 | where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
),
(
 union app("ai3").requests, app("ai3").dependencies
 | where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"
)
票数 2
EN

Stack Overflow用户

发布于 2020-08-04 18:02:29

您也可以在门户中的Azure工作簿中这样做,但是,与其传递查询文本中的所有应用in,您的查询实际上应该是

代码语言:javascript
运行
复制
union requests, dependencies
| where operation_Id == "eec42c35781a8e4199c420b8fda7bf87"

然后从资源选择器中选择要运行查询的应用程序,该应用程序允许多选择。

还可以将操作id、表、时间范围、资源转换为参数等:

该工作簿的一个工作示例为json:

代码语言:javascript
运行
复制
{
  "version": "Notebook/1.0",
  "items": [
    {
      "type": 9,
      "content": {
        "version": "KqlParameterItem/1.0",
        "crossComponentResources": [
          "value::selected"
        ],
        "parameters": [
          {
            "id": "75168f58-a753-45aa-97d9-89bf8f99d18e",
            "version": "KqlParameterItem/1.0",
            "name": "timeRange",
            "label": "Time Range",
            "type": 4,
            "isRequired": true,
            "value": {
              "durationMs": 86400000
            },
            "typeSettings": {
              "selectableValues": [
                {
                  "durationMs": 300000
                },
                {
                  "durationMs": 900000
                },
                {
                  "durationMs": 1800000
                },
                {
                  "durationMs": 3600000
                },
                {
                  "durationMs": 14400000
                },
                {
                  "durationMs": 43200000
                },
                {
                  "durationMs": 86400000
                },
                {
                  "durationMs": 172800000
                },
                {
                  "durationMs": 259200000
                },
                {
                  "durationMs": 604800000
                },
                {
                  "durationMs": 1209600000
                },
                {
                  "durationMs": 2419200000
                },
                {
                  "durationMs": 2592000000
                },
                {
                  "durationMs": 5184000000
                },
                {
                  "durationMs": 7776000000
                }
              ],
              "allowCustom": true
            },
            "timeContext": {
              "durationMs": 86400000
            }
          },
          {
            "id": "4e02493e-dbbe-478a-8992-d0897a4cb92c",
            "version": "KqlParameterItem/1.0",
            "name": "operationId",
            "type": 1,
            "isRequired": true,
            "value": "eec42c35781a8e4199c420b8fda7bf87",
            "timeContext": {
              "durationMs": 86400000
            }
          },
          {
            "id": "6a545372-8f82-43bc-b77c-9074c1ff18d0",
            "version": "KqlParameterItem/1.0",
            "name": "tables",
            "label": "Tables",
            "type": 2,
            "isRequired": true,
            "multiSelect": true,
            "quote": "",
            "delimiter": ",",
            "value": [
              "requests",
              "dependencies"
            ],
            "typeSettings": {
              "additionalResourceOptions": []
            },
            "jsonData": "[\"requests\", \"dependencies\", \"traces\", \"exceptions\"]",
            "timeContext": {
              "durationMs": 86400000
            }
          },
          {
            "id": "da2d5bd6-cdfe-43c1-b6d6-0a211d74953b",
            "version": "KqlParameterItem/1.0",
            "name": "Resources",
            "type": 5,
            "isRequired": true,
            "multiSelect": true,
            "quote": "'",
            "delimiter": ",",
            "query": "resources | where type =~ \"microsoft.insights/components\"\r\n| project id, name, selected=0, group=resourceGroup | order by 1 asc",
            "crossComponentResources": [
              "value::selected"
            ],
            "value": [
            ],
            "typeSettings": {
              "limitSelectTo": 10,
              "additionalResourceOptions": []
            },
            "timeContext": {
              "durationMs": 86400000
            },
            "queryType": 1,
            "resourceType": "microsoft.resourcegraph/resources"
          }
        ],
        "style": "above",
        "queryType": 1,
        "resourceType": "microsoft.resourcegraph/resources"
      },
      "name": "parameters - 0"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "union {tables}\r\n| where operation_Id == \"{operationId}\"",
        "size": 0,
        "title": "Operation \"{operationId}\" in {tables} over {timeRange:label}",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "timeRange",
        "queryType": 0,
        "resourceType": "microsoft.insights/components",
        "crossComponentResources": [
          "{Resources}"
        ]
      },
      "name": "query - 1"
    }
  ],
  "fallbackResourceIds": [
    "Azure Monitor"
  ],
  "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63216888

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档