树可视化效果Tree visualizations

工作簿通过树网格支持分层视图。Workbooks support hierarchical views via tree-grids. 在树中可以展开某些行进入下一级别,以获得向下钻取体验。Trees allow some rows to be expandable into the next level for a drill-down experience.

以下示例显示了已可视化为树网格的容器运行状况指标(工作集大小)。The example below shows container health metrics (working set size) visualized as a tree grid. 此处的顶级节点是 Azure Kubernetes 服务 (AKS) 节点,下一级别是 Pod,最终级别是容器。The top-level nodes here are Azure Kubernetes Service (AKS) nodes, the next level are pods, and the final level are containers. 请注意,仍可以像在网格中那样设置列的格式(热度地图、图标、链接)。Notice that you can still format your columns like in a grid (heatmap, icons, link). 在本例中,基础数据源是具有 AKS 日志的 Log Analytics 工作区。The underlying data source in this case is a Log Analytics workspace with AKS logs.

磁贴摘要视图的屏幕截图Screenshot of tile summary view

添加树网格Adding a tree grid

  1. 单击“编辑”工具栏项,将工作簿切换到编辑模式。Switch the workbook to edit mode by clicking on the Edit toolbar item.
  2. 依次选择“添加”、“添加查询”,将日志查询控件添加到工作簿。Select Add then Add query to add a log query control to the workbook.
  3. 选择“日志”作为查询类型,并选择资源类型(例如 Application Insights)以及目标资源。Select the query type as Log, resource type (for example, Application Insights), and the resources to target.
  4. 使用查询编辑器输入用于分析的 KQLUse the Query editor to enter the KQL for your analysis
    requests
    | summarize Requests = count() by ParentId = appName, Id = name
    | extend Kind = 'Request', Name = strcat('🌐 ', Id)
    | union (requests
    | summarize Requests = count() by Id = appName
    | extend Kind = 'Request', ParentId = '', Name = strcat('📱 ', Id))
    | project Name, Kind, Requests, Id, ParentId
    | order by Requests desc
    
  5. 将可视化效果设置为“网格”Set the visualization to Grid
  6. 选择“列设置”按钮打开“设置”窗格Select the Column Settings button to open the settings pane
  7. 在底部的“树/分组依据设置”部分,设置:In the Tree/Group By Settings section at the bottom, set:
    • 树类型:Parent/ChildTree Type: Parent/Child
    • ID 字段:IdId Field: Id
    • 父 ID 字段:ParentIdParent Id Field: ParentId
    • 要显示展开器的列:NameShow the expander on: Name
    • 选中“展开树的最高级别”复选框。Select Expand the top level of the tree check box.
  8. 在顶部的“列”部分,设置:In Columns section at the top, set:
    • ID - 列呈现器:HiddenId - Column Renderer: Hidden
    • 父 ID - 列呈现器:HiddenParent Id - Column Renderer: Hidden
    • 请求 - 列呈现器:Bar,颜色:Blue,最小值:0Requests - Column Renderer: Bar, Color: Blue, Minimum Value: 0
  9. 选择窗格底部的“保存并关闭”按钮。Select the Save and Close button at the bottom of the pane.

屏幕截图,其中的磁贴摘要视图包含上述查询和设置。Screenshot of tile summary view with the above query and settings.

树设置Tree settings

设置Setting 说明Explanation
Id Field 网格中每一行的唯一 ID。The unique ID of every row in the grid.
Parent Id Field 当前行的父级的 ID。The ID of the parent of the current row.
Show the expander on 要显示树展开器的列。The column on which to show the tree expander. 树网格通常会隐藏其 ID 和父 ID 字段,因为这些数据的可读性不是很好。It is common for tree grids to hide their ID and parent ID field because they are not very readable. 相对而言,包含易于阅读的值的字段(例如实体名称)上会显示展开器。Instead, the expander appears on a field with a more readable value like the name of the entity.
Expand the top level of the tree 如果选中该展开器,树网格会在顶级位置展开。If checked, the tree grid will be expanded at the top level. 如果你希望在默认情况下显示更多信息,这会很有用。Useful if you want to show more information by default.

在网格中分组Grouping in a grid

分组使你可以使用简单得多的查询来生成类似于上述视图的分层视图。Grouping allows you to build hierarchical views similar to the ones above with significantly simpler queries. 在树的内部节点上确实会丢失聚合,但这在某些情况下是可以接受的。You do lose aggregation at the inner nodes of the tree, but that will be acceptable for some scenarios. 当基础结果集无法转换为适当的自由格式(例如,警报、运行状况和指标数据)时,请使用“分组依据”生成树状视图。Use Group By to build tree views when the underlying result set cannot be transformed into a proper free form, for example: alert, health, and metric data.

使用分组添加树Adding a tree using grouping

  1. 单击“编辑”工具栏项,将工作簿切换到编辑模式。Switch the workbook to edit mode by clicking on the Edit toolbar item.
  2. 依次选择“添加”、“添加查询”,将日志查询控件添加到工作簿。Select Add then Add query to add a log query control to the workbook.
  3. 选择“日志”作为查询类型,并选择资源类型(例如 Application Insights)以及目标资源。Select the query type as Log, resource type (for example, Application Insights) and the resources to target.
  4. 使用查询编辑器输入用于分析的 KQLUse the Query editor to enter the KQL for your analysis
    requests
    | summarize Requests = count() by App = appName, RequestName = name
    | order by Requests desc
    
  5. 将可视化效果设置为“网格”。Set the visualization to Grid.
  6. 选择“列设置”按钮打开“设置”窗格。Select the Column Settings button to open the settings pane.
  7. 在底部的“树/分组依据设置”部分,设置:In the Tree/Group By Settings section at the bottom, set:
    • 树类型:Group ByTree Type: Group By
    • 分组依据:AppGroup By: App
    • 接下来的分组依据:NoneThen By: None
    • 选中“展开树的最高级别”复选框。Select Expand the top level of the tree check box.
  8. 在顶部的“列”部分,设置:In Columns section at the top, set:
    • 应用 - 列呈现器:HiddenApp - Column Renderer: Hidden
    • 请求 - 列呈现器:Bar,颜色:Blue,最小值:0Requests - Column Renderer: Bar, Color: Blue, Minimum Value: 0
  9. 选择窗格底部的“保存并关闭”按钮。Select the Save and Close button at the bottom of the pane.

屏幕截图,显示在工作簿中创建树可视化效果Screenshot showing the creation of a tree visualization in workbooks

后续步骤Next steps