从工作簿固定时,Azure 仪表板未更新为新的时间范围

Azure dashboard is not getting updated with new time range when pinned from workbook

我想在地图中可视化一些数据,因此我使用了工作簿。我没有在查询中设置时间范围,因为时间范围应该可以在仪表板中配置。将特定图块固定到仪表板后,地图不会在时间范围更改时更新。当我更改工作簿中的时间范围时,它按预期工作。

请找到我在工作簿中尝试过的 Kusto 查询:

let mainTable = union customEvents
    | extend name =replace("\n", "", name)
    | where iif('*' in ("*"), 1 == 1, name in ("*"))
    | where true;
let queryTable = mainTable;
let cohortedTable = queryTable
    | extend dimension = client_CountryOrRegion
    | extend dimension = iif(isempty(dimension), "<undefined>", dimension)
    | summarize hll = hll(itemId) by tostring(dimension)
    | extend Events = dcount_hll(hll)
    | order by Events desc
    | serialize rank = row_number()
    | extend dimension = iff(rank > 5, 'Other', dimension)
    | summarize merged = hll_merge(hll) by tostring(dimension)
    | project ['Country or region'] = dimension, Counts = dcount_hll(merged);
cohortedTable

您对此的意见非常有帮助。提前致谢

为了在仪表板时间范围更新时更新查询,工作簿中的查询需要使用 time range parameter:

https://docs.microsoft.com/en-us/azure/azure-monitor/visualize/workbooks-overview#dashboard-time-ranges

Pinned workbook query parts will respect the dashboard's time range if the pinned item is configured to use a Time Range parameter. The dashboard's time range value will be used as the time range parameter's value, and any change of the dashboard time range will cause the pinned item to update. If a pinned part is using the dashboard's time range, you will see the subtitle of the pinned part update to show the dashboard's time range whenever the time range changes.

Additionally, pinned workbook parts using a time range parameter will auto refresh at a rate determined by the dashboard's time range. The last time the query ran will appear in the subtitle of the pinned part.

If a pinned step has an explicitly set time range (does not use a time range parameter), that time range will always be used for the dashboard, regardless of the dashboard's settings. The subtitle of the pinned part will not show the dashboard's time range, and the query will not auto-refresh on the dashboard. The subtitle will show the last time the query executed.

您需要将工作簿更新为具有时间范围参数,然后更新该查询步骤以在查询文本中使用该时间范围参数,例如

let mainTable = union customEvents
    | where timestamp {TimeRange}  // reference the time range parameter in the query text
    | extend name =replace("\n", "", name)
    | where iif('*' in ("*"), 1 == 1, name in ("*"))
    | where true;
let queryTable = mainTable;
let cohortedTable = queryTable
    | extend dimension = client_CountryOrRegion
    | extend dimension = iif(isempty(dimension), "<undefined>", dimension)
    | summarize hll = hll(itemId) by tostring(dimension)
    | extend Events = dcount_hll(hll)
    | order by Events desc
    | serialize rank = row_number()
    | extend dimension = iff(rank > 5, 'Other', dimension)
    | summarize merged = hll_merge(hll) by tostring(dimension)
    | project ['Country or region'] = dimension, Counts = dcount_hll(merged);
cohortedTable

或在编辑查询时从 UX 的时间范围下拉列表中选择时间范围参数(对于基于日志的查询,如果这是对 ADX 数据源的查询,其中时间范围不是ux,你必须在查询文本中使用时间范围参数)

如果您将使用此类查询(引用时间范围参数)的查询步骤固定到仪表板,则仪表板知道如何将仪表板的时间范围“注入”到查询中。 (如果没有时间范围参数,我们可以通过多种(简单的)方式 尝试 来注入时间范围,但是根据查询的具体操作,查询 有效但不正确)

请参阅上面的时间范围参数 link,了解有关使用时间范围参数的方式的详细信息,以及各种可用的语法,有一些方法可以获取开始、结束、持续时间、分桶等信息,等等,参数语法中的时间范围。