How to use the Time range grain of the Dashboard?

91971187 25 Reputation points
2024-03-06T10:30:42.2566667+00:00

I see here that using {TimeRange:grain} allow to use the time range grain of the dashboard.

Unfortunately when I try it in a summarize operator (| summarize avg(duration) by bin(timestamp, {TimeRange:grain})) I get the error Query could not be parsed at '{'

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,661 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. AnuragSingh-MSFT 21,551 Reputation points Moderator
    2024-03-07T09:37:04.7633333+00:00

    91971187, I see that you are working with Azure Portal Dashboard, where you have pinned the query from a LA workspace as mentioned in this article - Create and share dashboards of Log Analytics data

    With Azure Portal Dashboard, there is no way to get the parameters in the query at the moment. The duration is specified based on which the tile shows the output of query and timeGrain will have to be hardcoded in the query as also shown here - Visualize a log query.

    Note that the suggestion provided above to use parameter names with "_ (underscore)" are for Azure Data Explorer dashboard which does not apply to Azure portal dashboard even when the queries being used are KQL.

    Apologies for the inconvenience. I would suggest posting this as an idea to the Azure Portal Feedback Forum for consideration by the portal team.

    I am also reaching out to Azure portal dashboard team to see if I can get additional details about it.

    1 person found this answer helpful.

  2. Clive Watson 7,866 Reputation points MVP Volunteer Moderator
    2024-03-06T11:12:02.41+00:00

    Is this a Workbook? "TimeRange" would need to be a named parameter, the grain is then calculated from that value. So does TimeRange exist, and it would need to be higher up the Workbook than the query that uses it?
    You can see here I have defined TimeRange, you can also see what the grain will be in the preview screen
    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.