Note
This documentation for Azure workbooks is now located at: https://learn.microsoft.com/en-us/azure/azure-monitor/visualize/workbooks-dropdowns Please do not edit this file. All up-to-date information is in the new location and documentation should only be updated there.
Drop downs allow user to collect one or more input values from a known set (e.g. select one of your app’s requests). Drop downs provide user-friendly way to collect arbitrary inputs from users. Drop downs are especially useful in enabling filtering in your interactive reports.
The easiest way to specify the list by providing a static list in the parameter setting. A more interesting way is to get the list dynamically via a KQL query. Parameter setting also allow you to specify whether it is single or multi-select, and if it is multi-select, how the result set should be formatted (delimiter, quotation, etc.).
-
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:
Environment
- Parameter type:
Drop down
- Required:
checked
- Allow multiple selection:
unchecked
- Get data from:
JSON
- Parameter name:
-
In the JSON Input text block, insert this json snippet:
[ { "value":"dev", "label":"Development" }, { "value":"ppe", "label":"Pre-production" }, { "value":"prod", "label":"Production", "selected":true } ]
-
Use the blue
Update
button. -
Choose 'Save' from the toolbar to create the parameter.
-
The Environment parameter will be a drop down with the three values.
If your query result/json contains an "group" field, the dropdown will display groups of values. Follow the above sample, but use the following json instead:
[
{ "value":"dev", "label":"Development", "group":"Development" },
{ "value":"dev-cloud", "label":"Development (Cloud)", "group":"Development" },
{ "value":"ppe", "label":"Pre-production", "group":"Test" },
{ "value":"ppe-test", "label":"Pre-production (Test)", "group":"Test" },
{ "value":"prod1", "label":"Prod 1", "selected":true, "group":"Production" },
{ "value":"prod2", "label":"Prod 2", "group":"Production" }
]
-
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:
RequestName
- Parameter type:
Drop down
- Required:
checked
- Allow multiple selection:
unchecked
- Get data from:
Query
- Parameter name:
-
In the JSON Input text block, insert this json snippet:
requests | summarize by name | order by name asc
-
Use the blue
Run Query
button. -
Choose 'Save' from the toolbar to create the parameter.
-
The RequestName parameter will be a drop down the names of all requests in the app.
-
Add a query control to the workbook and select an Application Insights resource.
-
In the KQL editor, enter this snippet
requests | where name == '{RequestName}' | summarize Requests = count() by bin(timestamp, 1h)
-
This expands on query evaluation time to:
requests | where name == 'GET Home/Index' | summarize Requests = count() by bin(timestamp, 1h)
-
Run query to see the results. Optionally, render it as a chart.
The query used in the dynamic drop down parameter above just returns a list of values that are rendered faithfully in the drop down. But what if you wanted a different display name, or one of these to be selected? Drop down parameters allow this via the value, label, selection and group columns.
The sample below shows how to get a list of Application Insights dependencies whose display names are styled with an emoji, has the first one selected, and is grouped by operation names.
dependencies
| summarize by operation_Name, name
| where name !contains ('.')
| order by name asc
| serialize Rank = row_number()
| project value = name, label = strcat('🌐 ', name), selected = iff(Rank == 1, true, false), group = operation_Name
Parameter | Explanation | Example |
---|---|---|
{DependencyName} |
The selected value | GET fabrikamaccount |
{DependencyName:label} |
The selected label | 🌐 GET fabrikamaccount |
{DependencyName:value} |
The selected value | GET fabrikamaccount |
See also: Parameter Options
The examples so far explicitly set the parameter to select only one value in the drop down. Drop down parameters also support multiple selection - enabling this is as simple as checking the the Allow multiple selection
option.
The user also have the option of specifying the format of the result set via the delimiter
and quote with
settings. The default just returns the values as a collection in this form: 'a', 'b', 'c'. They also have the option to limit the number of selections.
The KQL referencing the parameter will need to change to work with the format of the result. The most common way to enable it is via the in
operator.
dependencies
| where name in ({DependencyName})
| summarize Requests = count() by bin(timestamp, 1h), name
Here is an example for multi-select drop down at work:
Dropdown parameters also allow the ability for authors to specify special values that will also appear in the dropdown:
- Any one
- Any three
- ...
- Any 100
- Any custom limit
- All
When these special items are selected, the parameter value will be automatically set to the specific number of items, or all values.
When the "All" option is selected, an additional field appears that allows the author to specify that a special value will be used for the parameter if the "All" option is selected. This is useful for cases where "All" could be a large number of items and could generate a very large query.
in this specific case, the string []
will be used instead of a value. this can be used to generate an empty array in the a logs query, like:
let selection = dynamic([{Selection}]);
SomeQuery
| where array_length(selection) == 0 or SomeField in (selection)
if all items are selected, the value of Selection
will be []
, producing an empty array for the selection
variable in the query. If no values are selected, the value of Selection
will be an empty string, also resulting in an empty array. If any values are selected, they will be formatted inside the dynamic part, causing the array to have those values. you can then test for array_length
of 0 to have the filter not apply or in
the array to filter on the values.
Other common examples use '*' as the special marker value when a parameter is required, and then test with
| where "*" in ({Selection}) or SomeField in ({Selection})