Note
This documentation for Azure workbooks is now located at: https://learn.microsoft.com/en-us/azure/azure-monitor/visualize/workbooks-criteria Please do not edit this file. All up-to-date information is in the new location and documentation should only be updated there.
When a query depends on many parameters, then the query will be stalled until each of it's parameters have been resolved. Sometimes a parameter could have a simple query that concatenates a string or performs a conditional evaluation. However these queries still make network calls to services that perform these basic operations and that increases the time it takes for a parameter to resolve a value. This results in long load times for complex workbooks.
Criteria Text parameters solve this issue, as an author can define a set of criteria based on previously specified parameters, which will be evaluated to provide a dynamic value. The main benefit of using Criteria parameters is that it has the ability to resolve values of previously specified parameters and perform simple conditional operations without making any network calls. Below is an example of such a use case.
Consider the conditional query below:
let metric = dynamic({Counter});
print tostring((metric.object == 'Network Adapter' and (metric.counter == 'Bytes Received/sec' or metric.counter == 'Bytes Sent/sec')) or (metric.object == 'Network' and (metric.counter == 'Total Bytes Received' or metric.counter == 'Total Bytes Transmitted')))
If the user is mainly focused on the metric.counter
object, essentially the value of the parameter isNetworkCounter
should be true, if the parameter Counter
has Bytes Received/sec
, Bytes Sent/sec
, Total Bytes Received
, or Total Bytes Transmitted
.
This can be translated to a criteria text parameter like so:
In the image above, the conditions will be evaluated from top to bottom and the value of the parameter isNetworkCounter
will take the value of which ever condition evaluates to true first. All conditions except for the default condition (the 'else' condition) can be reordered to get the desired outcome.
-
Start with a workbook with at least one existing parameter 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: rand
- Parameter type: Text
- Required: checked
- Get data from: Query
- Enter
print rand(0-1)
into the query editor. This parameter will output a value between 0-1.
- Choose 'Save' from the toolbar to create the parameter.
Note: The first parameter in the workbook will not show the
Criteria
tab
- In the table with the 'rand' parameter, click on the blue Add Parameter button.
- In the new parameter pane that pops up enter:
- Parameter name: randCriteria
- Parameter type: Text
- Required: checked
- Get data from: Criteria
- A grid should appear, click on 'Edit' next to the blank text box, this will bring up a 'Criteria Settings' form. Refer to Criteria Settings form for the description of each field.
- Enter the data below to populate the first Criteria, then click 'OK'.
- First operand: rand
- Operator: >
- Value from: Static Value
- Second Operand: 0.25
- Value from: Static Value
- Result is: is over 0.25
-
Click on edit, next to the condition
Click edit to specify a result for the default condition.
, this will edit the default condition.Note: For the default condition, everthing should be disabled except for the last
Value from
andResult is
fields. -
Enter the data below to populate the default condition, then click 'OK'.
- Value from: Static Value
- Result is: is 0.25 or under
- Save the Parameter
- Click on the refresh button on the workbook, to see the
randCriteria
parameter in action. It's value will be based on the the value ofrand
!
Form fields | Description |
---|---|
First operand | This is a dropdown consisting of parameter names that have already been created. The value of the parameter will be used on the left hand side of the comparison |
Operator | The operator used to compare the first and the second operands. Can be a numerical or string evaluation. The operator is empty will disable the Second operand as only the First operand is required. |
Value from | If set to Parameter , a dropdown consisting of parameters that have already been created will be shown. The value of that parameter will be used on the right hand side of the comparison.If set to Static Value , a text box will be shown where an author can enter a value for the right hand side of the comparison. |
Second Operand | Will be either a dropdown menu consisting of created parameters, or a textbox depending on the above Value from selection. |
Value from | If set to Parameter , a dropdown consisting of parameters that have already been created will be shown. The value of that parameter will be used for the return value of the current parameter.If set to Static Value :
Expression
|
Result is | Will be either a dropdown menu consisting of created parameters, or a textbox depending on the above Value from selection. The textbox will be evaluated as the final result of this Criteria Settings form. |