视图设计器到工作簿转换常见任务View designer to workbooks conversion common tasks

视图设计器是 Azure Monitor 的一项功能,它让你能够创建自定义视图,帮助你通过图表、列表和时间线将 Log Analytics 工作区中的数据可视化。View designer is a feature of Azure Monitor that allows you to create custom views to help you visualize data in your Log Analytics workspace, with charts, lists, and timelines. 这些元素已逐步淘汰,取而代之的是除这些功能外还可提供其他功能的工作簿。They are being phased out and replaced with workbooks which provide additional functionality. 本文详细介绍将视图转换为工作簿时的常见任务。This article details tasks that are common in converting views to workbooks.

使用预设视图设计器模板快速入门Quickstart with preset view designer templates

Log Analytics 工作区中的工作簿已经具有模板,可以匹配视图设计器中的某些视图。Workbooks in Log Analytics workspaces already have templates made to match some of the views in view designer. 在“视图设计器指南”类别下,选择“视图设计器转换指南”以了解你的选项或选择其中一个预设模板 。Under the View Designer Guides category, select View Designer Transition Guide to learn about your options or select one of the preset templates.

示例模板

启用时间范围筛选器Enabling time range filter

视图设计器具有内置的默认时间范围筛选器,但是,默认情况下,工作簿中不会启用此设置。View designer has a built-in default time range filter, however, in workbooks this setting is not enabled by default. 工作簿使用户能够创建自己的时间范围筛选器,这些筛选器可能更适用于他们的数据日志。Workbooks do allow users to create their own time range filters that might be more applicable to their data logs. 生成筛选器的步骤如下所示:The steps to generate the filter are listed below:

选择“添加参数”选项。Select the Add parameters option. 默认样式设置为“药丸”。The default Style is set to Pills.

添加参数

选择“添加参数”按钮。Select the Add Parameter button.

添加参数

在侧栏菜单的“参数名称”文本框中,键入 TimeRange。From the sidebar menu, in the Parameter name textbox, type TimeRange. 将“参数类型”设置为“时间范围选取器”。Set Parameter Type as Time Range Picker. 勾选“必需?”复选框。Select the Required? checkbox.

“参数”菜单

使用侧栏菜单左上角的“保存”按钮保存参数。Save the parameter in the upper left corner of the sidebar menu. 默认情况下,可将下拉列表保留为“取消”,或选择默认的 TimeRange 值,如 24 小时。You can leave the dropdown as unset by default or select a default TimeRange value, such as 24 hours. 选择“完成编辑”。Select Done Editing.

可以通过在参数名称周围添加大括号 {},在查询中使用参数。Parameters can be used in queries by adding curly braces {} around your parameter name. 请参阅有关参数的工作簿文档,获取有关参数的详细信息。More details on parameters can be found in the Workbooks documentation on parameters.

使用 TimeRange 参数更新查询Updating queries with the TimeRange parameter

选项 1:从“时间范围”下拉列表中选择 TimeRangeOption 1: Select TimeRange from the Time Range dropdown

时间参数

选项 2:更新日志查询Option 2: Update your log queries

在查询中添加行:| where TimeGenerated {TimeRange}如以下示例所示:In your query add the line: | where TimeGenerated {TimeRange} as in the following example:

原始查询Original query

search * 
| summarize count() by Type

更新后的查询Updated query

search * 
| where TimeGenerated {TimeRange} 
| summarize count() by Type

包括列表Including a List

大多数视图设计器视图都包含一个列表,你可以在工作簿中重现此标准列表。Most of the view designer views include a list, and you can reproduce this standard list in a workbook.

磁贴列表

通过单击单元格选项中的“添加查询”来添加可视化效果。Add a visualization by clicking Add query from the cell options.

添加参数

视图设计器使用与原始示例中的语法匹配的默认查询。View designer employs a default query that matches the syntax from the Original example. 可以通过将查询更改为更新后的表单来进行更新,如以下示例所示:This can be updated by changing the query to the updated form as in the following example:

原始查询Original query

search * 
| summarize AggregatedValue = count() by Type

更新后的查询Updated query

search * 
| summarize Count = count() by Type

这将生成如下所示的列表:This will generate a list that looks similar to the following:

列表示例

启用迷你图Enabling sparklines

网格的一项常见功能是添加迷你图来汇总随时间变化的各种数据模式。A common feature for grids is to add sparklines to summarize various data patterns over time. 视图设计器为所有列表提供“启用迷你图”功能,工作簿也是如此。View designer offers the Enable Sparklines feature for all lists, as does workbooks. 若要在数据中包含与视图设计器匹配的迷你图,请将数据与原始查询联接,如以下示例所示:To include sparklines in your data that match view designer,join the data with your original query as in the following example:

原始查询Original query

search *
| summarize AggregatedValue = count() by Type) on Type

更新后的查询Updated query

search * 
| summarize AggregatedValue = count() by Type
| join kind = inner (search * 
    | make-series Trend = count() default=0 on TimeGenerated from {TimeRange:start} to {TimeRange:end} step {TimeRange:grain} by Type) on Type
| project Type, AggregatedValue, Trend

选择“列设置”。Select Column Settings. 列设置Column Settings

将“列呈现器”下拉列表更新为“Spark 区域”。Update the Column renderer dropdown to be a Spark area. 迷你图Sparklines

保存设置,并再次运行查询以将表更新为包含迷你图。Save the settings and run the query again to update your table to include a sparkline.

生成的网格类似于以下示例:迷你图示例The resulting grid will look similar to following: Sparkline example

高级单元格设置Advanced cell settings

若要镜像视图设计器,你可以执行更改工作簿单元格大小或向日志添加 pin 和外部链接等任务。To mirror view designer, you can perform tasks such as changing the size of workbook cells or adding pins and external links to logs.

若要访问“高级设置”,请选择每个单元底部的齿轮图标。To access Advanced Settings select the gear icon at the bottom of each cell.

高级设置

这将显示包含各种选项的菜单:This will display a menu with various options:

“高级设置”设置

若要添加指向外部查询的 pin 和链接,请选择相应的复选框。To add a pin and a link to an external query select the corresponding checkboxes. 若要向单元格添加标题,请将所需标题键入“图表标题”部分。To add a title to your cell, type the desired title into the Chart title section.

默认情况下,任何工作簿单元格都设置为占用整个页面宽度,但你可以在“高级设置”菜单的“样式”选项卡下缩小单元格来进行调整 By default any workbooks cell is set to take up the entire page width, but you can adjust this by scaling the cell down under the Style tab of the Advanced Settings menu

“高级设置”样式

其他参数Additional parameters

选择“添加参数”以在工作簿中新建参数。Select Add Parameter to create a new parameter in your workbook.

若要选择订阅,请在侧菜单的“参数名称”字段中键入“订阅”,然后从“参数类型”下拉列表中选择“订阅选取器”To select a Subscription, type Subscription into the Parameter name field in the side menu and select Subscription Picker from the Parameter type dropdown

“订阅”菜单

若要选择资源,请在侧菜单的“参数名称”字段中键入“资源”,然后从“参数类型”下拉列表中选择“资源选取器”。To select a Resource, type Resource into the Parameter name field in the side menu and select Resource Picker from the Parameter type dropdown.

“资源”菜单

这将插入下拉列表,以便你访问各种订阅和资源。This will insert dropdowns to let you access your various subscriptions and resources.

订阅资源下拉列表

后续步骤Next steps