图形可视化效果Graph visualizations

工作簿支持根据日志中的数据可视化任意图形,以显示监视实体之间的关系。Workbooks support visualizing arbitrary graphs based on data from logs to show the relationships between monitoring entities.

下图显示了通过各种端口从一台计算机流入/流出外部计算机的数据。The graph below show data flowing in/out of a computer via various ports to/from external computers. 这些数据按类型(计算机、端口与外部 IP)以不同的颜色显示,边缘大小对应于不同计算机之间的流动数据量。It is colored by type (computer vs. port vs. external IP) and the edge sizes correspond to the amount of data flowing in-between. 基础数据来自针对 VM 连接的 KQL 查询。The underlying data comes from KQL query targeting VM connections.

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

添加图形Adding a graph

  1. 单击“编辑”工具栏项,将工作簿切换到编辑模式。Switch the workbook to edit mode by clicking on the Edit toolbar item.

  2. 使用“添加查询”链接将日志查询控件添加到工作簿。Use the Add query link 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. 使用查询编辑器输入用于分析的 KQL。Use the Query editor to enter the KQL for your analysis.

    let data = dependencies
    | summarize Calls = count() by App = appName, Request = operation_Name, Dependency = name
    | extend RequestId = strcat(App, '::', Request);
    let links = data
    | summarize Calls = sum(Calls) by App, RequestId
    | project SourceId = App, TargetId = RequestId, Calls, Kind = 'App -> Request'
    | union (data
        | project SourceId = RequestId, TargetId = Dependency, Calls, Kind = 'Request -> Dependency');
    let nodes = data
    | summarize Calls = sum(Calls) by App
    | project Id = App, Name = App, Calls, Kind = 'App'
    | union (data
        | summarize Calls = sum(Calls) by RequestId, Request
        | project Id = RequestId, Name = Request, Calls, Kind = 'Request')
    | union (data
        | summarize Calls = sum(Calls) by Dependency
        | project Id = Dependency, Name = Dependency, Calls, Kind = 'Dependency');
    nodes
    | union (links)
    
  5. 将可视化效果设置为“图形”Set the visualization to Graph

  6. 选择“图形设置”按钮打开“设置”窗格Select the Graph Settings button to open the settings pane

  7. 在底部的“布局字段”中,设置:In Layout Fields at the bottom, set:

    • 节点 ID:IdNode Id: Id
    • 源 ID:SourceIdSource Id: SourceId
    • 目标 ID:TargetIdTarget Id: TargetId
    • 边缘标签:NoneEdge Label: None
    • 边缘大小:CallsEdge Size: Calls
    • 节点大小:NoneNode Size: None
    • 着色类型:CategoricalColoring Type: Categorical
    • 节点颜色字段:KindNode Color Field: Kind
    • 调色板:PastelColor palette: Pastel
  8. 在顶部的“节点格式设置”中,设置:In Node Format Settings at the top, set:

    • 使内容靠上 - 使用列:Name,列呈现器:TextTop Content- Use Column: Name, Column Renderer: Text
    • 使内容居中 - 使用列:Calls,列呈现器:Big Number,调色板:NoneCenter Content- Use Column: Calls, Column Renderer: Big Number, Color Palette: None
    • 使内容靠下 - 使用列:Kind,列呈现器:TextBottom Content- Use Column: Kind, Column Renderer: Text
  9. 选择窗格底部的“保存并关闭”按钮。Select the Save and Close button at the bottom of the pane.

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

图形设置Graph settings

设置Setting 说明Explanation
Node Id 选择提供图形上节点的唯一 ID 的列。Selects a column that provides the unique ID of nodes on the graph. 列的值可以是字符串或数字。Value of the column can be string or a number.
Source Id 选择为图形上的边缘提供源节点 ID 的列。Selects a column that provides the IDs of source nodes for edges on the graph. 值必须映射到节点 ID 列中的值。Values must map to a value in the Node Id column.
Target Id 选择为图形上的边缘提供目标节点 ID 的列。Selects a column that provides the IDs of target nodes for edges on the graph. 值必须映射到节点 ID 列中的值。Values must map to a value in the Node Id column.
Edge Label 选择在图形上提供边缘标签的列。Selects a column that provides edge labels on the graph.
Edge Size 选择提供指标宽度所基于的指标的列。Selects a column that provides the metric on which the edge widths will be based on.
Node Size 选择提供节点区域所基于的指标的列。Selects a column that provides the metric on which the node areas will be based on.
Coloring Type 用于选择节点着色方案。Used to choose the node coloring scheme.

节点着色类型Node coloring types

着色类型Coloring Type 说明Explanation
None 所有节点都具有相同的颜色。All nodes have the same color.
Categorical 根据结果集中某列的值或类别为节点分配颜色。Nodes are assigned colors based on the value or category from a column in the result set. 在上述示例中,着色基于结果集的列“Kind”。In the example above, the coloring is based on the column Kind of the result set. 支持的调色板为 DefaultPastelCool toneSupported palettes are Default, Pastel, and Cool tone.
Field Based 在此类型中,列提供要用于节点的特定 RGB 值。In this type, a column provides specific RGB values to use for the node. 提供最大灵活性,但通常需要做更多工作才能实现。Provides the most flexibility but usually requires more work to enable.

节点格式设置Node format settings

图形创建者可以指定节点不同部分(顶部、左侧、中心、右侧和底部)的内容。Graphs authors can specify what content goes to the different parts of a node: top, left, center, right, and bottom. 图形可以自由使用工作簿支持的任何呈现器(文本、大数字、走势图、图标等)。Graphs can use any of renderers workbooks supports (text, big number, spark lines, icon, etc.).

基于字段的节点着色Field based node coloring

  1. 单击“编辑”工具栏项,将工作簿切换到编辑模式。Switch the workbook to edit mode by clicking on the Edit toolbar item.

  2. 使用“添加查询”链接将日志查询控件添加到工作簿。Use the Add query link 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. 使用查询编辑器输入用于分析的 KQL。Use the Query editor to enter the KQL for your analysis.

    let data = dependencies
    | summarize Calls = count() by App = appName, Request = operation_Name, Dependency = name
    | extend RequestId = strcat(App, '::', Request);
    let links = data
    | summarize Calls = sum(Calls) by App, RequestId
    | project SourceId = App, TargetId = RequestId, Calls, Kind = 'App -> Request'
    | union (data
       | project SourceId = RequestId, TargetId = Dependency, Calls, Kind = 'Request -> Dependency');
    let nodes = data
    | summarize Calls = sum(Calls) by App
    | project Id = App, Name = App, Calls, Color = 'FD7F23'
    | union (data
       | summarize Calls = sum(Calls) by RequestId, Request
       | project Id = RequestId, Name = Request, Calls, Color = 'B3DE8E')
    | union (data
       | summarize Calls = sum(Calls) by Dependency
       | project Id = Dependency, Name = Dependency, Calls, Color = 'C9B3D5');
    nodes
    | union (links)
    
  5. 将可视化效果设置为“图形”Set the visualization to Graph

  6. 选择“图形设置”按钮打开“设置”窗格。Select the Graph Settings button to open the settings pane.

  7. 在底部的“布局字段”中,设置:In Layout Fields at the bottom, set:

    • 节点 ID:IdNode Id:Id
    • 源 ID:SourceIdSource Id: SourceId
    • 目标 ID:TargetIdTarget Id: TargetId
    • 边缘标签:NoneEdge Label: None
    • 边缘大小:CallsEdge Size: Calls
    • 节点大小:NodeNode Size: Node
    • 着色类型:Field BasedColoring Type: Field Based
    • 节点颜色字段:ColorNode Color Field: Color
  8. 在顶部的“节点格式设置”中,输入以下内容。In Node Format Settings at the top, enter the following.

    • 在“顶部内容集”中,设置以下项:In Top Content, set:
      • 使用列:NameUse Column: Name.
      • 列呈现器:TextColumn renderer: Text.
    • 在“中心内容”中,设置以下项:In Center Content, set:
      • 使用列:CallsUse column: Calls
      • 列呈现器:Big NumberColumn Renderer: Big Number
      • 调色板:NoneColor palette: None
    • 在“底部内容”中,设置以下项:In Bottom Content, set:
      • 使用列:KindUse column: Kind
      • 列呈现器:TextColumn renderer: Text.
  9. 选择窗格底部的“保存并关闭”按钮。Select the Save and Close button at the bottom of the pane.

显示使用字段基节点着色创建图形可视化效果的屏幕截图。Screenshot showing the creation of a graph visualization with field base node coloring.

后续步骤Next steps