网格可视化效果Grid visualizations

网格或表是向用户呈现数据的常用方式。Grids or tables are a common way to present data to users. 工作簿允许用户为网格列单独设置样式,以便在报告中提供丰富的 UI。Workbooks allow users to individually style the columns of the grid to provide a rich UI for their reports.

以下示例显示了一个网格,其中组合了图标、热度地图和缩微条形图,以呈现复杂的信息。The example below shows a grid that combines icons, heatmaps, and spark-bars to present complex information. 该工作簿还提供了排序控件、搜索框和“转到分析”按钮。The workbook also provides sorting, a search box and a go-to-analytics button.

基于日志的网格的屏幕截图Screenshot of log based grid

添加基于日志的网格Adding a log-based grid

  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. 使用查询编辑器输入用于分析(例如,内存低于阈值的 VM)的 KQLUse the Query editor to enter the KQL for your analysis (for example, VMs with memory below a threshold)
  5. 将可视化效果设置为“网格”Set the visualization to Grid
  6. 根据需要设置其他参数 - 例如时间范围、大小、调色板和图例。Set other parameters if needed - like time range, size, color palette, and legend.

基于日志的网格查询的屏幕截图Screenshot of log based grid query

日志图表参数Log chart parameters

参数Parameter 说明Explanation 示例Example
Query Type 要使用的查询类型。The type of query to use. 日志、Azure Resource Graph 等Log, Azure Resource Graph, etc.
Resource Type 目标资源类型。The resource type to target. Application Insights、Log Analytics 或 Azure-firstApplication Insights, Log Analytics, or Azure-first
Resources 要从中获取指标值的一组资源。A set of resources to get the metrics value from. MyApp1MyApp1
Time Range 用于查看日志图表的时间范围。The time window to view the log chart. 过去 1 小时、过去 24 小时,等等Last hour, Last 24 hours, etc.
Visualization 要使用的可视化效果。The visualization to use. 网格Grid
Size 控件的垂直大小。The vertical size of the control. 小、中、大或完整Small, medium, large, or full
Query 以图表可视化效果所需的格式返回数据的任何 KQL 查询。Any KQL query that returns data in the format expected by the chart visualization. requests | summarize Requests = count() by namerequests | summarize Requests = count() by name

简单网格Simple Grid

工作簿可将 KQL 结果呈现为简单的表。Workbooks can render KQL results as a simple table. 以下网格显示了应用中每个请求类型的请求数和唯一用户数。The grid below shows the count of requests and unique users per requests type in an app.

requests
| where name !endswith('.eot')
| summarize Requests = count(), Users = dcount(user_Id) by name
| order by Requests desc

编辑模式下基于日志的网格的屏幕截图Screenshot of a log based grid in edit mode

网格样式Grid styling

尽管纯表可显示数据,但很难阅读,并且见解并不总是显而易见的。While a plain table shows data, it is hard to read and insights won't always be apparent. 设置网格样式有助于更轻松地阅读和解释数据。Styling the grid can help make it easier to read and interpret the data.

下面是上一部分中的相同网格,样式为热度地图。Below is the same grid from the previous section styled as heatmaps.

基于日志的网格的屏幕截图,其中列的样式为热度地图Screenshot of a log based grid with columns styled as heatmaps

下面是样式为条形图的相同网格:基于日志的网格的屏幕截图,其中列的样式为条形图Here is the same grid styled as bars: Screenshot of a log based grid with columns styled as bars

设置网格列的样式Styling a grid column

  1. 选择查询控件工具栏上的“列设置”按钮。Select the Column Setting button on the query control toolbar.
  2. 在“编辑列设置”中,选择要设置样式的列。In the Edit column settings, select the column to style.
  3. 选择列呈现器(例如 heatmap、bar​​、bar underneath 等)以及用于设置列样式的相关设置。Choose a column renderer (for example heatmap, bar, bar underneath, etc.) and related settings to style your column.

以下示例将“请求”列的样式设置为条形图:Below is an example that styles the Request column as a bar:

基于日志的网格的屏幕截图,其中“请求”列的样式为条形图。Screenshot of a log based grid with request column styled as a bar.

列呈现器Column renderers

列呈现器Column Renderer 说明Explanation 其他选项Additional Options
Automatic 默认值 - 根据列类型使用最适合的呈现器。The default - uses the most appropriate renderer based on the column type.
Text 将列值呈现为文本。Renders the column values as text.
Right Aligned 与 text 类似,只不过它是右对齐的。Similar to text except that it is right aligned.
Date/Time 呈现可读日期时间字符串。Renders a readable date time string.
Heatmap 根据单元格的值为网格单元格着色。Colors the grid cells based on the value of the cell. 调色板和用于缩放的最小/最大值。Color palette and min/max value used for scaling.
Bar 根据单元格的值在单元格旁边呈现一个条形图。Renders a bar next to the cell based on the value of the cell. 调色板和用于缩放的最小/最大值。Color palette and min/max value used for scaling.
Bar underneath 根据单元格的值在单元格的底部附近呈现一个条形图。Renders a bar near the bottom of the cell based on the value of the cell. 调色板和用于缩放的最小/最大值。Color palette and min/max value used for scaling.
Composite bar 使用该行中的指定列呈现复合条形图。Renders a composite bar using the specified columns in that row. 有关详细信息,请参阅复合条形图Refer Composite Bar for details. 以相应颜色呈现条形图的列以及显示在条形图顶部的标签。Columns with corresponding colors to render the bar and a label to display at the top of the bar.
Spark bars 根据单元格中动态数组的值,在单元格中呈现缩微条形图。Renders a spark bar in the cell based on the values of a dynamic array in the cell. 例如,屏幕截图中顶部的“趋势”列。For example, the Trend column from the screenshot at the top. 调色板和用于缩放的最小/最大值。Color palette and min/max value used for scaling.
Spark lines 根据单元格中动态数组的值,在单元格中呈现缩微线形图。Renders a spark line in the cell based on the values of a dynamic array in the cell. 调色板和用于缩放的最小/最大值。Color palette and min/max value used for scaling.
Icon 根据单元格中的文本值呈现图标。Renders icons based on the text values in the cell. 支持的值包括:cancelledcriticaldisablederrorfailedinfononependingstoppedquestionsuccessunknownwarninguninitializedresourceupdownleftrighttrenduptrenddown4321Sev0Sev1Sev2Sev3Sev4FiredResolvedAvailableUnavailableDegradedUnknownBlankSupported values include: cancelled, critical, disabled, error, failed, info, none, pending, stopped, question, success, unknown, warning uninitialized, resource, up, down, left, right, trendup, trenddown, 4, 3, 2, 1, Sev0, Sev1, Sev2, Sev3, Sev4, Fired, Resolved, Available, Unavailable, Degraded, Unknown, and Blank.
Link 呈现单击时的链接或执行可配置操作。Renders a link that when clicked or performs a configurable action. 如果只希望该项成为链接,请使用此列呈现器。Use this if you only want the item to be a link. 使用 Make this item a link 设置,任何其他类型也可成为链接。Any of the other types can also be a link by using the Make this item a link setting. 有关详细信息,请参阅下面的链接操作For more information see Link Actions below.
Location 根据区域 ID 呈现友好 Azure 区域名称。Renders a friendly Azure region name based on a region ids.
Resource type 根据资源类型 ID 呈现友好资源类型字符串Renders a friendly resource type string based on a resource type id
Resource 根据资源 ID 呈现友好资源名称和链接Renders a friendly resource name and link based on a resource id 用于显示资源类型图标的选项Option to show the resource type icon
Resource group 根据资源组 ID 呈现友好资源组名称和链接。如果该单元格的值不是资源组,则将其转换为资源组。Renders a friendly resource group name and link based on a resource group id. If the value of the cell is not a resource group, it will be converted to one. 用于显示资源组图标的选项Option to show the resource group icon
Subscription 根据订阅 ID 呈现友好订阅名称和链接。如果该单元格的值不是订阅,则将其转换为订阅。Renders a friendly subscription name and link based on a subscription id. if the value of the cell is not a subscription, it will be converted to one. 用于显示订阅图标的选项。Option to show the subscription icon.
Hidden 在网格中隐藏列。Hides the column in the grid. 当默认查询返回的列多于所需的列,但不需要 project-away 时,此选项非常有用Useful when the default query returns more columns than needed but a project-away is not desired

如果选择了 Link 呈现器或选中了“将此项设置为链接”复选框,则创建者可以配置在选择该单元格时将发生的链接操作。If the Link renderer is selected or the Make this item a link checkbox is selected, then the author can configure a link action that will occur on selecting the cell. 这通常会将用户带到其他视图(其中包含来自该单元格的上下文),或者可能会打开一个 URL。THis usually is taking the user to some other view with context coming from the cell or may open up a url.

自定义格式设置Custom formatting

工作簿还使用户能够设置其单元格值的数字格式。Workbooks also allows users to set the number formatting of their cell values. 通过单击“自定义格式设置”复选框(如果可用)即可完成此操作。They can do so by clicking on the Custom formatting checkbox when available.

格式选项Formatting option 说明Explanation
Units 列的单位 - 百分比、计数、时间、字节、计数/时间、字节/时间等各种选项。例如,值 1234 的单位可以设置为毫秒,呈现为 1.234 秒。The units for the column - various options for percentage, counts, time, byte, count/time, bytes/time, etc. For example, the unit for a value of 1234 can be set to milliseconds and it's rendered as 1.234 s.
Style 呈现的格式 - 十进制、货币、百分比。The format to render it as - decimal, currency, percent.
Show group separator 用于显示组分隔符的复选框。Checkbox to show group separators. 在美国将 1234 呈现为 1,234。Renders 1234 as 1,234 in the US.
Minimum integer digits 要使用的最小整数位数(默认为 1)。Minimum number of integer digits to use (default 1).
Minimum fractional digits 要使用的最小小数位数(默认为 0)。Minimum number of fractional digits to use (default 0).
Maximum fractional digits 要使用的最大小数位数。Maximum number of fractional digits to use.
Minimum significant digits 要使用的最小有效位数(默认为 1)。Minimum number of significant digits to use (default 1).
Maximum significant digits 要使用的最大有效位数。Maximum number of significant digits to use.
Custom text for missing values 如果数据点没有值,则显示此自定义文本而不是显示空白。When a data point does not have a value, show this custom text instead of a blank.

自定义日期格式设置Custom date formatting

当创建者已指定将列设置为 Date/Time 呈现器时,创建者可使用“自定义日期格式设置”复选框来指定自定义日期格式设置选项。When the author has specified that a column is set to the Date/Time renderer, the author can specify custom date formatting options by using the Custom date formatting checkbox.

格式选项Formatting option 说明Explanation
Style 将日期呈现为短、长、完整格式或将时间呈现为短或长时间格式的格式。The format to render a date as short, long, full formats, or a time as short or long time formats.
Show time as 允许创建者决定是显示本地时间(默认)还是 UTC 时间。Allows the author to decide between showing the time in local time (default), or as UTC. UTC/时区信息可能不会显示,具体取决于选择的日期格式样式。Depending on the date format style selected, the UTC/time zone information may not be displayed.

自定义列宽设置Custom column width setting

创建者可使用“列设置”中的“自定义列宽”字段来自定义网格中任何列的宽度 。The author can customize the width of any column in the grid using the Custom Column Width field in Column Settings.

列设置的屏幕截图,其中以红色框突出显示了“自定义列宽”字段

如果该字段保留图中的黑色文本,则将根据列中的字符数和可见列数自动确定宽度。If the field is left black, then the width will be automatically determined based on the number of characters in the column and the number of visible columns. 默认单位为“ch”(字符)。The default unit is "ch" (characters).

选择标签中的蓝色“(当前宽度)”按钮将会用所选列的当前宽度填充文本字段。Selecting the blue (Current Width) button in the label will fill the text field with the selected column's current width. 如果“自定义宽度”字段中存在值但没有度量单位,则将使用默认值。If a value is present in the custom width field with no unit of measurement, then the default will be used.

可用的度量单位包括:The units of measurement available are:

度量单位Unit of measurement 定义Definition
chch 字符(默认)characters (default)
像素px 像素pixels
frfr 小数单位fractional units
% percentagepercentage

输入验证 - 如果验证失败,则会在字段下面弹出一条红色指导消息,但用户仍可以应用该宽度。Input validation - if validation fails, a red guidance message will popup below the field, but the user can still apply the width. 如果输入中存在值,则将对其进行分析。如果找不到有效的度量单位,则将使用默认单位。If a value is present in the input, it will be parsed out. If no valid unit of measure is found, then the default will be used.

没有最小/最大宽度,因为这由创建者自行决定。There is no minimum/maximum width as this is left up to the author's discretion. 对于隐藏列,禁用“自定义列宽度”字段。The custom column width field is disabled for hidden columns.

示例Examples

缩微线形图和底部条形图Spark lines and bar underneath

下面的示例按请求名称显示了请求数及其趋势。The example below shows requests counts and its trend by request name.

requests
| make-series Trend = count() default = 0 on timestamp from ago(1d) to now() step 1h by name
| project-away timestamp
| join kind = inner (requests
    | summarize Requests = count() by name
    ) on name
| project name, Requests, Trend
| order by Requests desc

基于日志的网格的屏幕截图,其中包含底部条形图和缩微线形图Screenshot of a log based grid with a bar underneath and a spark line

包含共享缩放和自定义格式设置的热度地图Heatmap with shared scales and custom formatting

此示例显示了各种请求持续时间指标及其计数。This example shows various request duration metrics and its counts. heatmap 呈现器使用设置中设置的最小值或计算列的最小值和最大值,并根据相对于列的最小值和最大值的单元格的值,从所选调色板分配背景色。The heatmap renderer uses the minimum values set in settings or calculates a minimum and maximum value for the column, and assigns a background color from the selected palette for the cell based on the value of the cell relative to the minimum and maximum value of the column.

requests
| summarize Mean = avg(duration), (Median, p80, p95, p99) = percentiles(duration, 50, 80, 95, 99), Requests = count() by name
| order by Requests desc

基于日志的网格的屏幕截图,其中热度地图跨列共享缩放Screenshot of a log based grid with a heatmap having a shared scale across columns

在上面的示例中,共享调色板(绿色或红色)和缩放用于为列(平均值、中间值、p80、p95 和 p99)着色。In the above example, a shared palette (green or red) and scale is used to color the columns (mean, median, p80, p95, and p99). 用于请求列的单独调色板(蓝色)。A separate palette (blue) used for the request column.

共享缩放Shared scale

获取共享缩放:To get a shared scale:

  1. 使用正则表达式来选择多个列以向它们应用设置。Use regular expressions to select more than one column to apply a setting to. 例如,将列名称设置为 Mean|Median|p80|p95|p99 以将它们全部选中。For example, set the column name to Mean|Median|p80|p95|p99 to select them all.
  2. 删除各个列的默认设置。Delete default settings for the individual columns.

这将导致新的多列设置为应用其设置以包含共享缩放。This will cause the new multi-column setting to apply its settings to include a shared scale.

基于日志的网格的屏幕截图,其中网格设置为获取跨列共享缩放Screenshot of a log based grid setting to get a shared scale across columns

用于表示状态的图标Icons to represent status

下面的示例显示了基于 p95 持续时间的自定义请求状态。The example below shows custom status of requests based on the p95 duration.

requests
| summarize p95 = percentile(duration, 95) by name
| order by p95 desc
| project Status = case(p95 > 5000, 'critical', p95 > 1000, 'error', 'success'), name, p95

基于日志的网格的屏幕截图,其中热度地图使用上述查询跨列共享缩放。Screenshot of a log based grid with a heatmap having a shared scale across columns using the query above.

支持的图标名称包括:cancelledcriticaldisablederrorfailedinfononependingstoppedquestionsuccessunknownwarning uninitializedresourceupdownleftrighttrenduptrenddown4321Sev0Sev1Sev2Sev3Sev4FiredResolvedAvailableUnavailableDegradedUnknownBlankSupported icon names include: cancelled, critical, disabled, error, failed, info, none, pending, stopped, question, success, unknown, warning uninitialized, resource, up, down, left, right, trendup, trenddown, 4, 3, 2, 1, Sev0, Sev1, Sev2, Sev3, Sev4, Fired, Resolved, Available, Unavailable, Degraded, Unknown, and Blank.

下面的说明将演示如何将阈值与链接结合使用来分配图标和打开不同的工作簿。The instructions below will show you how to use thresholds with links to assign icons and open different workbooks. 网格中的每个链接将为该 Application Insights 资源打开不同的工作簿模板。Each link in the grid will open up a different workbook template for that Application Insights resource.

  1. 选择“编辑”工具栏项,将工作簿切换到编辑模式。Switch the workbook to edit mode by selecting Edit toolbar item.
  2. 选择“添加”,然后选择“添加查询”。Select Add then Add query.
  3. 将“数据源”更改为“JSON”,并将“可视化效果”更改为“网格” 。Change the Data source to "JSON" and Visualization to "Grid".
  4. 输入以下查询。Enter the following query.
[ 
    { "name": "warning", "link": "Community-Workbooks/Performance/Performance Counter Analysis" },
    { "name": "info", "link": "Community-Workbooks/Performance/Performance Insights" },
    { "name": "error", "link": "Community-Workbooks/Performance/Apdex" }
]
  1. 运行查询。Run query.

  2. 选择“列设置”以打开设置。Select Column Settings to open the settings.

  3. 从“列”中选择“名称”。Select "name" from Columns.

  4. 在“列呈现器”下,选择“阈值”。Under Column renderer, choose "Thresholds".

  5. 输入并选择以下“阈值设置”。Enter and choose the following Threshold Settings.

    运算符Operator Value 图标Icons
    == warningwarning 警告Warning
    == errorerror 失败Failed

    包含以上设置的“编辑列设置”选项卡的屏幕截图。

    保留默认行不变。Keep the default row as is. 可输入你喜欢的任何文本。You may enter whatever text you like. “文本”列接受字符串格式的输入,并使用列值和单位(如果指定)填充该列。The Text column takes a String format as an input and populates it with the column value and unit if specified. 例如,如果 warning 为列值,则文本可为“{0} {1} link!”,它将显示为“warning link!”。For example, if warning is the column value the text can be "{0} {1} link!", it will be displayed as "warning link!".

  6. 选择“将此项设置为链接”框。Select the Make this item a link box.

    1. 在“打开视图”下,选择“工作簿(模板)”。Under View to open, choose "Workbook (Template)".
    2. 在“链接值来源”下,选择“链接”。Under Link value comes from, choose "link".
    3. 选择“在上下文边栏选项卡中打开链接”框。Select the Open link in Context Blade box.
    4. 在“工作簿链接设置”中选择以下设置Choose the following settings in Workbook Link Settings
      1. 在“模板 ID 来源”下,选择“列”。Under Template Id comes from, choose "Column".
      2. 在“列”下,选择“链接”。Under Column choose "link".

    包含以上设置的链接设置的屏幕截图。

  7. 从“列”中选择“链接”。Select "link" from Columns. 在“列呈现器”旁的“设置”下,选择“(隐藏列)”。Under Settings next to Column renderer, select (Hide column).

  8. 若要更改“名称”列的显示名称,请选择“标签”选项卡。在以“名称”为其“列 ID”的行上,在“*列标签”下输入要显示的名称。To change the display name of the "name" column select the Labels tab. On the row with "name" as its Column ID, under *Column Label enter the name you want displayed.

  9. 选择“应用”Select Apply

包含以上设置的“网格中的阈值”的屏幕截图

小数单位百分比Fractional units percentages

小数单位 (fr) 是各种网格中常用的动态度量单位。The fractional unit (fr) is a commonly used dynamic unit of measurement in various types of grids. 当窗口大小/分辨率发生变化时,fr 宽度也随之更改。As the window size/resolution changes, the fr width changes as well.

下面的屏幕截图显示了一个具有八列的表,其中每个列的宽度相同,均为 1fr。The screenshot below shows a table with eight columns that are 1fr width each and all equal widths. 随着窗口大小的变化,每列的宽度会按比例变化。As the window size changes, the width of each column changes proportionally.

网格中列的屏幕截图,其中每个列的宽度值为 1frScreenshot of columns in grid with column width value of 1fr each

下图显示了相同的表,只不过第一列的宽度设置为 50%。The image below shows the same table, except the first column is set to 50% width. 这会动态地将列设置为总网格宽度的一半。This will set the column to half of the total grid width dynamically. 除非窗口大小太小,否则调整窗口大小将继续保留 50% 的宽度。Resizing the window will continue to retain the 50% width unless the window size gets too small. 这些动态列的最小宽度取决于其内容。These dynamic columns have a minimum width based on their contents. 剩余 50% 的网格划分为全部 8 个小数单位。The remaining 50% of the grid is divided up by the eight total fractional units. 下面的“种类”列设置为 2fr,因此它占据了剩余空间的四分之一。The "kind" column below is set to 2fr, so it takes up one-fourth of the remaining space. 由于其他列均为 1fr,它们各自占网格右半部分的八分之一。As the other columns are 1fr each, they each take up one-eighth of the right half of the grid.

网格中列的屏幕截图,其中有一列的宽度值为 50%,其余每列均为 1frScreenshot of columns in grid with 1 column width value of 50% and the rest as 1fr each

可将 fr、%、px 和 ch 宽度结合使用,并且其工作方式与前面的示例类似。Combining fr, %, px, and ch widths is possible and works similarly to the previous examples. 设置为静态单位(ch 和 px)的宽度是硬常量,即使更改了窗口/分辨率,宽度也不会更改。The widths that are set by the static units (ch and px) are hard constants that won't change even if the window/resolution is changed. 设置为 % 的列将占据总网格宽度的百分比(由于前面的最小宽度,因此可能并非完全如此)。The columns set by % will take up their percentage based on the total grid width (might not be exact due to previously minimum widths). 设置为 fr 的列只会根据分配的小数单位数来拆分剩余的网格空间。The columns set with fr will just split up the remaining grid space based on the number of fractional units they are allotted.

网格中列的屏幕截图,其中使用了各种不同的宽度单位Screenshot of columns in grid with assortment of different width units used

后续步骤Next steps