- 04 Aug 2024
- 6 Minutes to read
- Print
- DarkLight
- PDF
Using the Dynamic Value Statement Simulator
- Updated on 04 Aug 2024
- 6 Minutes to read
- Print
- DarkLight
- PDF
All examples on this page contain demo data.
Axonius provides the Dynamic Value Statement Simulator tool to effectively debug Dynamic Value Statements. You can use the Simulator to create Dynamic Value Statements in Enforcement Sets that produce valid results as opposed to fallback (default) values.
When users run Enforcement Sets configured with Dynamic Value Statements, although the statements have been validated successfully, the Enforcement Action fields are sometimes configured with fallback (default) values instead of the expected calculated results. This can be due to a number of reasons, including:
- Function failure - If a function in the Dynamic Value Statement fails or is unable to execute successfully, it does not return a valid result.
- Empty Fields - Empty fields in the Dynamic Value Statement can prevent proper calculations.
- Type Mismatch - Discrepancies between the type of value stored in the field (e.g., string, integer, boolean) and the Action Form field type may cause errors.
Use the Simulator to:
- Simulate the execution of a Dynamic Value Statement on individual assets returned from a query, making it easier to isolate and diagnose issues specific to that asset.
- Review the results displayed by the Simulator for each component in the statement. This breakdown helps you identify which part of the statement is not functioning as intended.
- Correct the statement. If you identify components that give an error or do not return the expected results, you can make adjustments and rerun the simulation until the desired outcomes are achieved.
To debug a Dynamic Value statement using the Simulator
- Make sure that the Dynamic Value statement is valid and that you have saved the Enforcement Set.
The Simulator works only on validated statements in saved Enforcement Sets. If not validated, a Syntax validation error occurs and the Simulator does not work.
- Above the Dynamic Value statement, click Simulate to activate the Simulator.
You can also enter the Simulator directly from the Wizard, after you have saved the Enforcement Set.
Simulator Mode opens, and the Simulator immediately selects a random asset to use in the simulation. The selected asset's name (max 10 characters) appears above the statement near Simulate on. Hover over the asset name to see the full name.
Hover on a component in the statement that you want the Simulator to test on the asset. Components include functions and adapter fields; the Simulator does not debug Enforcement Action configuration fields. It is recommended to first test the innermost component, as if it results in an error, simulation of any outer component will result in the same error. The selected component is highlighted in turquoise, and the simulation immediately executes on that component. The Result of the simulation appears below the statement box.
- When the component is compatible with the statement, the Simulator shows the results in terms of Field type, Value type, and Value.
- When the component is incompatible with the statement or has an empty value, the phrase is highlighted in red, and an error is shown in the Results area.
If the Result shows an error (in red), click Exit Simulator Mode to leave Simulator mode and fix the component. Then, run the Simulator again from the beginning of this procedure.
You can click the asset to view its asset profile.
You can click the Replace Asset icon to have the system automatically select a different asset for the simulation so that you can test various scenarios.
When you finish debugging the statement, click Exit Simulator Mode to leave the Simulator.
The Enforcement Set is now ready to run - either manually or according to a configured schedule. Learn more about running Enforcement Sets.
Example 1 - Running the Simulator on an All Statement
The following example shows how you can use the Simulator on an All statement.
Validate the statement and save the Enforcement Set.
Click Simulate on the validated statement.
The statement enters Simulator Mode and the system randomly selects a host name, for instance win7b, as the asset on which to simulate the statement.
Hover over the innermost component in the statement. The device.specific_data.data.hostname field is highlighted in turquoise, and results are displayed below the statement.
Now hover over the count function. The Simulator immediately shows the results of this function on the asset.
The results of the set_value function are those of the count function. The field on the configuration dialog (form.field_integer) of the Enforcement Action is filled with the value 3 (in this example).
Example 2 - Running the Simulator on an All Statement
The following is another example showing how you can use the Simulator on an All statement.
Validate the statement and save the Enforcement Set.
Click Simulate on the validated statement. The statement enters Simulator Mode and the system randomly selects an asset on which to simulate the statement (in this example, dbnginx-53971222-prod). Hover over each component of the statement, as shown in the following screens. The component currently being analyzed is highlighted in turquoise. In each case, you can see the result for the component below the statement.
Check that this is the desired result, and if not, click the Replace Asset icon to run on a different asset. Adjust the statement or query as required. Remember to validate the statement and save the Enforcement Set before you run the Simulator again.
Example 3 - Debugging a Switch/Case Statement
The following example shows how you can use the Simulator to debug a Switch/Case statement.
Validate the statement and save the Enforcement Set.
Click Simulate on the validated statement.
The statement enters Simulator Mode and the system randomly selects an asset (in this case, name begins with Domain Cont) on which to simulate the statement.
Check the then clause of the statement: Hover over the adapter field. It is highlighted in turquoise. The results are displayed below the statement box.
Click the Replace Asset icon to replace the asset (in this case, to ML-Lab), and you then get valid results for the field as in step 2. Next, hover over multiply. The following error occurs.
Leave the Simulator, correct the statement to run the max function on the array so that multiply works, validate the statement, and save the Enforcement Set to save these changes.
Re-enter the Simulator, hover over multiply, and you can see that the results are now valid.
Now check the switch clause of the statement. An error occurs when performing the subtract function.
Leave Simulator Mode and update the statement to run the max function on the second item in the subtract function. Validate the statement and save the Enforcement Set to save these changes. Run the Simulator again, hover over subtract, and the results are now valid.
Now check the case clause of the statement. An error occurs in this component due to an empty asset field.
Leave Simulator Mode and replace this field with the number 90.0. Validate the statement and save the Enforcement Set to save these changes. Run the Simulator again, hover over gt, and you can see that the results are now valid.
For more information about Dynamic Value statements, see the following::
Dynamic Value Statement Concepts
Creating Enforcement Action Dynamic Value Statements
Enforcement Action Dynamic Value Statement Syntax Table
Useful Tips and Tricks for Working with Dynamic Value Statements
Using the Syntax Helper
Using the Dynamic Value Statement Wizard
Using the Dynamic Value Statement Simulator
"All" Statement Syntax
Switch/Case Statement Syntax
Using Functions, Operators, and Keywords
Dynamic Value Statement Examples and Use Cases
For more information about working with Enforcement Sets, see the following:
Enforcement Center Overview
Enforcement Sets Page
Creating Enforcement Sets
Managing Enforcement Sets
Using Predefined Enforcement Sets
Testing an Enforcement Set
Creating Enforcement Action Dynamic Value Statements
Scheduling Enforcement Set Runs
Viewing Enforcement Set Run History
Duplicating Enforcement Sets
Viewing Editing and Deleting Enforcement Sets
Terminating an Enforcement Set Run
Running Enforcement Sets