Time parameters allow users to set the time context of analysis and is used by almost all reports. It is relatively simple to setup and use - allowing authors to specify the time ranges to show in the drop down, including the option for custom time ranges.
- Start with an empty workbook in edit mode.
- Choose Add parameters from the links within the workbook.
- Click on the blue Add Parameter button.
- In the new parameter pane that pops up enter:
- Parameter name:
TimeRange
- Parameter type:
Time range picker
- Required:
checked
- Available time ranges: Last hour, Last 12 hours, Last 24 hours, Last 48 hours, Last 3 days, Last 7 days and Allow custom time range selection
- Parameter name:
- Choose 'Save' from the toolbar to create the parameter.
This is how the workbook will look like in read-mode.
- Add a query control to the workbook and select an Application Insights resource.
- Most workbook controls support a Time Range scope picker. Open the Time Range drop down and select the
{TimeRange}
in the time rang parameters group at the bottom. - This binds the time range parameter to the time range of the chart. The time scope of the sample query is now Last 24 hours.
- Run query to see the results
- Add a query control to the workbook and select an Application Insights resource.
- In the KQL, enter a time scope filter using the parameter:
| where timestamp {TimeRange}
- This expands on query evaluation time to
| where timestamp > ago(1d)
which is the time range value of the parameter. - Run query to see the results
- Add a text control to the workbook.
- In the markdown, enter
The chosen time range is {TimeRange:label}
- Choose Done Editing
- The text control will show text: The chosen time range is Last 24 hours
Parameter | Explanation | Example |
---|---|---|
{TimeRange} |
Time range label | Last 24 hours |
{TimeRange:label} |
Time range label | Last 24 hours |
{TimeRange:value} |
Time range value | > ago(1d) |
{TimeRange:query} |
Time range query | > ago(1d) |
{TimeRange:start} |
Time range start time | 3/20/2019 4:18 PM |
{TimeRange:end} |
Time range end time | 3/21/2019 4:18 PM |
{TimeRange:grain} |
Time range grain | 30m |
{TimeRange:startISO} |
Time range start time ISO format | 2019-11-02T01:04:00.000Z |
{TimeRange:endISO} |
Time range end time ISO format | 2019-12-02T01:04:00.000Z |
{TimeRange:startDateISO} |
Start date ISO format | 2019-11-02T00:00:00.000Z |
{TimeRange:endDateISO} |
End date ISO format | 2019-12-02T00:00:00.000Z |
{TimeRange:durationISO} |
Time range duration ISO format | PT24H |
{TimeRange:seconds} |
Time range duration in seconds | 86400 |
requests
| make-series Requests = count() default = 0 on timestamp from {TimeRange:start} to {TimeRange:end} step {TimeRange:grain}