图表可视化效果Chart visualizations

工作簿允许以图表形式提供监视数据。Workbooks allow monitoring data to be presented as charts. 支持的图表类型包括折线图、条形图、分类条形图、面积图、散点图、饼图和时间图。Supported chart types include line, bar, bar categorical, area, scatter plots, pie, and time. 作者可以选择自定义图表的高度、宽度、调色板、图例、标题和非数据消息等,以及使用图表设置自定义轴类型和序列颜色。Authors can choose to customize the height, width, color palette, legend, titles, no-data message, etc. of the chart and customize axis types and series colors using chart settings.

工作簿支持日志和指标数据源的图表。Workbooks support charts for both logs and metric data sources.

日志图表Log charts

Azure Monitor 日志为资源所有者提供了有关其应用和基础结构的详细信息。Azure Monitor logs gives resources owners detailed information about the workings of their apps and infrastructure. 与指标不同,默认不收集日志信息,需要以某种方式启动收集。Unlike metrics, log information is not collected by default and requires some kind of collection on-boarding. 但是,当日志存在时,它会提供许多有关资源状态的信息以及对诊断有用的数据。However, when present logs provide a lot of information about the state of the resource and data useful for diagnostics. 工作簿允许将日志数据显示为直观的图表,以供用户分析。Workbooks allow presenting log data as visual charts for user analysis.

添加日志图表Adding a log chart

以下示例显示了过去几天内对应用的请求的趋势。The example below shows the trend of requests to an app over the previous days.

  1. 选择“编辑”工具栏项,将工作簿切换到编辑模式。Switch the workbook to edit mode by selecting 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. 使用查询编辑器输入用于分析(例如,请求的趋势)的 KQLUse the Query editor to enter the KQL for your analysis (for example, trend of requests).
  5. 将可视化效果设置为下列其中一项:“面积图”、“条形图”、“条形图(分类)”、“折线图”、“饼图”、“散点图”或“时间图”。 Set the visualization to one of: Area, Bar, Bar (categorical), Line, Pie, Scatter, or Time.
  6. 根据需要设置其他参数 - 例如时间范围、可视化效果、大小、调色板和图例。Set other parameters if needed - like time range, visualization, size, color palette, and legend.

处于编辑模式的日志图表的屏幕截图Screenshot of log chart in edit mode

日志图表参数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. 面积图、条形图、折线图、饼图、散点图、时间图、分类条形图Area, Bar, Line, Pie, Scatter, Time, bar categorical
Size 控件的垂直大小。The vertical size of the control. 小、中、大或完整Small, medium, large, or full
Color palette 要在图表中使用的调色板。The color palette to use in the chart. 在多指标或分段模式下将被忽略。Ignored in multi-metric or segmented mode. 蓝色、绿色、红色,等等Blue, green, red, etc.
Legend 用于图例的聚合函数。The aggregation function to use for the legend. 值的总和或平均值,或者最大值、最小值、第一个值或最后一个值Sum or Average of values or Max, Min, First, Last value
Query 以图表可视化效果所需的格式返回数据的任何 KQL 查询。Any KQL query that returns data in the format expected by the chart visualization. requests | make-series Requests = count() default = 0 on timestamp from ago(1d) to now() step 1hrequests | make-series Requests = count() default = 0 on timestamp from ago(1d) to now() step 1h

时序图表Time-series charts

使用工作簿中的查询控件,可以轻松创建时序图,如面积图、条形图、折线图、散点图和时间图。Time series charts like area, bar, line, scatter, and time can be easily created using the query control in Workbooks. 关键是在结果集中具有时间和指标信息。The key is having time and metric information in the result set.

简单时序Simple time-series

下面的查询返回包含两个列的表:时间戳和请求 。The query below returns a table with two columns: timestamp and Requests. 查询控件将时间戳用于 X 轴,将请求用于 Y 轴 。The query control uses timestamp for the X-axis and Requests for the Y-axis.

requests
| summarize Requests = count() by bin(timestamp, 1h)

简单时序日志折线图的屏幕截图。Screenshot of a simple time-series log line chart.

具有多个指标的时序Time-series with multiple metrics

下面的查询返回包含三个列的表:时间戳、请求和用户 。The query below returns a table with three columns: timestamp, Requests, and Users. 查询控件将时间戳用于 X 轴,将请求和用户用作 Y 轴上的单独序列 。The query control uses timestamp for the X-axis and Requests & Users as separate series on the Y-axis.

requests
| summarize Requests = count(), Users = dcount(user_Id) by bin(timestamp, 1h)

具有多个指标日志折线图的时序的屏幕截图。Screenshot of a time-series with multiple metrics log line chart.

分段时序Segmented Time-series

下面的查询返回包含三个列的表:时间戳、请求和 RequestName,其中 RequestName 是包含请求名称的分类列 。The query below returns a table with three columns: timestamp, Requests, and RequestName where RequestName is a categorical column with the names of requests. 这里的查询控件将时间戳用于 X 轴,并为每个 RequestName 的值添加一个序列 。The query control here uses timestamp for the X-axis and adds a series per value of RequestName.

requests
| summarize Request = count() by bin(timestamp, 1h), RequestName = name

分段时序日志折线图的屏幕截图。Screenshot of a segmented time-series log line chart.

汇总与建立序列Summarize vs. make-series

上一节中的示例使用 summarize 运算符,因为它更易于理解。The examples in the previous section use the summarize operator because it is easier to understand. 不过,summarize 确实有一个比较大的限制,即:如果 Bucket 中没有任何项,它将省略结果行。However, summarize does have a major limitation as it omits the results row if there are no items in the bucket. 它可以根据空 Bucket 位于时间范围的前半段还是后半段来改变图表时间窗口的效果。It can have the effect of shifting the chart time window depending on whether the empty buckets are in the front or backside of the time range.

通常最好使用 make-series 运算符来创建时序数据,它有为空 Bucket 提供默认值的选项。It is usually better to use the make-series operator to create time series data, which has the option to provide default values for empty buckets.

以下查询使用 make-series 运算符。The following query uses the make-series operator.

requests
| make-series Requests = count() default = 0 on timestamp from ago(1d) to now() step 1h by RequestName = name

下面的查询使用 summarize 运算符显示类似的图表The query below shows a similar chart with the summarize operator

requests
| summarize Request = count() by bin(timestamp, 1h), RequestName = name

即使基础结果集不同也是如此。Even though the underlying result set is different. 用户只需将可视化效果设置为面积图、折线图、条形图或时间图,工作簿将负责处理其余的工作。All a user has to do is set the visualization to area, line, bar, or time and Workbooks will take care of the rest.

由生成序列查询创建的日志折线图的屏幕截图Screenshot of a log line chart made from a make-series query

分类条形图或直方图Categorical bar chart or histogram

分类图允许用户在图表的 X 轴上表示维度或列,这在直方图中特别有用。Categorical charts allow users to represent a dimension or column on the X-axis of a chart, this is especially useful in histograms. 下面的示例通过请求结果代码显示请求的分布情况。The example below shows the distribution of requests by their result code.

requests
| summarize Requests = count() by Result = strcat('Http ', resultCode)
| order by Requests desc

查询返回两个列:“请求”指标和“结果”类别 。The query returns two columns: Requests metric and Result category. “结果”列的每个值都将在图表中获得其自己的条形,其高度与请求指标成比例 。Each value of the Result column will get its own bar in the chart with height proportional to the Requests metric.

请求的分类条形图(按结果代码)的屏幕截图Screenshot of a categorical bar chart for requests by result code

饼图Pie charts

饼图可以呈现数字比例的可视化效果。Pie charts allow the visualization of numerical proportion. 下面的示例按请求结果代码显示请求的比例。The example below shows the proportion of requests by their result code.

requests
| summarize Requests = count() by Result = strcat('Http ', resultCode)
| order by Requests desc

查询返回两个列:“请求”指标和“结果”类别 。The query returns two columns: Requests metric and Result category. “结果”列的每个值都将在饼图中获得其自己的切片,其大小与“请求”指标成比例 。Each value of the Result column will get its own slice in the pie with size proportional to the Requests metric.

饼图的屏幕截图,其中有代表结果代码的切片Screenshot of a pie chart with slices representing result code

指标图表Metric charts

大多数 Azure 资源都会发出有关状态和运行状况的指标数据(例如 CPU 利用率、存储可用性、数据库事务计数、失败的应用请求等)。Most Azure resources emit metric data about state and health (for example, CPU utilization, storage availability, count of database transactions, failing app requests, etc.). 工作簿允许将此类数据可视化为时序图。Workbooks allow the visualization of this data as time-series charts.)

添加指标图表Adding a metric chart

以下示例将显示前一个小时内存储帐户中的事务数。The following example will show the number of transactions in a storage account over the prior hour. 这使存储所有者可以查看事务趋势并查找行为中的异常。This allows the storage owner to see the transaction trend and look for anomalies in behavior.

  1. 选择“编辑”工具栏项,将工作簿切换到编辑模式。Switch the workbook to edit mode by selecting the Edit toolbar item.
  2. 使用“添加指标”链接将指标控件添加到工作簿。Use the Add metric link to add a metric control to the workbook.
  3. 选择资源类型(例如“存储帐户”)、目标资源、指标命名空间和名称,以及要使用的聚合。Select a resource type (for example, Storage Account), the resources to target, the metric namespace and name, and the aggregation to use.
  4. 根据需要设置其他参数 - 例如时间范围、拆分依据、可视化效果、大小和调色板。Set other parameters if needed - like time range, split-by, visualization, size, and color palette.

处于编辑模式的指标图表的屏幕截图Screenshot of metric chart in edit mode

指标图表参数Metric chart parameters

参数Parameter 说明Explanation 示例Example
Resource Type 目标资源类型。The resource type to target. “存储”或“虚拟机”。Storage or Virtual Machine.
Resources 要从中获取指标值的一组资源。A set of resources to get the metrics value from. MyStorage1MyStorage1
Namespace 包含该指标的命名空间。The namespace with the metric. 存储 > BlobStorage > Blob
Metric 要可视化的指标。The metric to visualize. 存储 > Blob > 事务Storage > Blob > Transactions
Aggregation 要应用到指标的聚合函数。The aggregation function to apply to the metric. Sum、Count、Average 等Sum, Count, Average, etc.
Time Range 用于查看指标的时间范围。The time window to view the metric in. 过去 1 小时、过去 24 小时,等等Last hour, Last 24 hours, etc.
Visualization 要使用的可视化效果。The visualization to use. 面积图、条形图、折线图、散点图、网格Area, Bar, Line, Scatter, Grid
Split By (可选)按维度拆分指标。Optionally split the metric on a dimension. 按地理类型列出事务Transactions by Geo type
Size 控件的垂直大小。The vertical size of the control. 小、中或大Small, medium, or large
Color palette 要在图表中使用的调色板。The color palette to use in the chart. 使用 Split by 参数时将被忽略。Ignored if the Split by parameter is used. 蓝色、绿色、红色,等等Blue, green, red, etc.

示例Examples

将按 API 名称拆分的事务显示为折线图:Transactions split by API name as a line chart:

按 API 名称拆分的存储事务指标折线图的屏幕截图Screenshot of a metric line chart for Storage transactions split by API name

将按响应类型拆分的事务显示为大型条形图:Transactions split by response type as a large bar chart:

按响应类型拆分的存储事务大型指标条形图的屏幕截图Screenshot of a large metric bar chart for Storage transactions split by response type

将平均延迟显示为散点图:Average latency as a scatter chart:

存储延迟指标散点图的屏幕截图Screenshot of a metric scatter chart for Storage latency

图表设置Chart settings

创建者可以使用图表设置来自定义图表轴中使用的字段、轴单位、自定义格式设置、范围、分组行为、图例和序列颜色。Authors can use chart settings to customize which fields are used in the chart axes, the axis units, custom formatting, ranges, grouping behaviors, legends, and series colors.

“设置”选项卡The settings tab

“设置”选项卡控件:The settings tab controls:

  • 轴设置,包括具有此功能的字段和自定义格式设置:允许用户将数字格式设置为轴值和自定义范围。The axis settings, including which fields, custom formatting that allows users to set the number formatting to the axis values and custom ranges.
  • 分组设置,包括用于以下设置的字段:在创建“其他”组之前的限制。Grouping settings, including which field, the limits before an "Others" group is created.
  • 图例设置,包括在底部显示指标(序列名称、颜色和数字)和/或图例(序列名称和颜色)。Legend settings, including showing metrics (series name, colors, and numbers) at the bottom, and/or a legend (series names and colors).

图表设置的屏幕截图。

自定义格式设置Custom formatting

数字格式设置选项包括:Number formatting options include:

格式选项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.234s.
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.

X 轴设置的屏幕截图。

“序列”选项卡The series tab

可通过序列设置选项卡调整为图表中的序列显示的标签和颜色。The series setting tab lets you adjust the labels and colors shown for series in the chart.

  • Series name 字段用于匹配数据中的序列,如果匹配,将显示相应的显示标签和颜色。The Series name field is used to match a series in the data and if matched, the display label and color will be displayed.
  • Comment 字段对模板作者很有用,作者添加此注释后,翻译人员可以用它对显示标签进行本地化。The Comment field is useful for template authors, as this comment may be used by translators to localize the display labels.

序列设置的屏幕截图。

后续步骤Next steps