Skip to main content
All CollectionsControl MonitoringAdaptive Automation
Advanced editor in the Test Builder
Advanced editor in the Test Builder
Updated over a week ago

The Advanced editor provides more flexibility and capability for building tests, especially when creating custom tests for nested properties. The Advance editor can be used to build on top of the logic built through the Builder tab or used independently. For example, if you started creating a test through the Builder tab, you can finish it through the Advance editor. The Advanced Editor will automatically convert the test logic built on the Builder tab as a JSON object on the Advance editor.

Before using the Advance editor to build custom test, ensure you know how to create a custom test.

Continuous syntax validation and guidance

When creating your JSON object for your custom test, the text editor continuously validates your the JSON syntax and logic so that you can receive instant feedback about the test logic you built or JSON syntax to have the most help when creating the test logic through our advance editor. The instant feedback will provide the specific lines the misconfigurations are found.

For example in the following image, there is no "operator" selected. The message indicates the line number followed by what the misconfiguration is. It can also suggest the potential solutions.

The text editor can also suggest values for you to use by enabling intelli-Sense. Enter ctrl + space to activate functionality of Intelli-Sense. Enter two quotes with a space (such as " ") and hover your mouse to view the suggested values; select the desired option to auto populate with that selected option.

Create test logic with Advance editor

Note: Each code block can have up to 70 lines.

On the Test Builder page, select the Advance editor tab.

The following code block displays the default JSON object:

{
"all": [
{
"fact": "",
"operator": "",
"value": ""
}
]
}

If you selected or added any values on the Builder tab, Advance editor displays the the converted JSON logic of the test on the Advance editor.

Let's discover what each of these properties mean.

  • Top-Level properties

    • "all": This represents a logical AND operation. All conditions within it must evaluate to true for the rule to be true.

    • "any": This represents a logical OR operation. Any of the conditions within it must evaluate to true for the rule to be true.

  • Nested properties

    • “fact”: Enter the evaluated property. In the Builder tab, this is the Attribute field.

    • “operator”: Select the comparison operator (for example, equal) between the "fact" and "value".

    • “value”: Enter the value to compare against the property in the fact.

Note: This is the structure or standard pattern for the JSON object within the Advance editor. The top-level properties can be nested, such as having a nested object with all and any. Each of these top-level properties must contain the specified nested properties ("fact", "operator", and "value").

Filtering criteria

You can add an additional filtering criteria. The filtering criteria can be deleted or edited. Ensure to select the Exclusion or Inclusion option.

After creating the test logic, ensure to save your changes.

Edit test logic with Advance editor

To modify the JSON object within the editor, select the edit icon near the top right above the code block. Ensure to save your changes.

You will not be able to save the conditions in the advanced editor until it is valid.

Switch between Builder and Advance editor tab

After saving your work, you can verify if the test logic you built in the Advance editor can be displayed in the Builder tab. This is not when you select the Save draft and continue button but the save button within the Advance editor tab.

If the conditions you've entered in the Advance editor can be shown in the Builder tab, you can seamlessly select the builder tab and the Builder tab will contain and display the logic there.

If the conditions you’ve created in the advanced editor are too complex for builder tab to automatically fill out the fields, then the tab will be greyed out as an indicator. Most of the time, test logic evaluating a nested property within an array cannot be shown in the Builder tab.

If you select the greyed out builder tab, you will receive a warning message and have the option to remove all of the test logic to go to the Builder tab (which is the Go to builder button) or continue your work on the Advance editor tab (which is the Stay on editor button).

Save a draft of your custom test

To save your custom test, you must resolve any JSON syntax issue or test logic. You can view the feedback underneath each code block to verify if your JSON object has any issues.

After building your draft custom test, on the Monitoring page, select your test. Within the Test logic section, you can view your JSON if the test logic you built was too complicated for your Builder tab.

JSON examples

The following sections showcase multiple scenarios when to use the Advance editor, what kind of test logic can be created through the Advance editor, and the example JSON syntax.

Multiple conditions

When you create a test to verify that both encryption is true and the region is us-west-2, you might need to add another condition. Here is an JSON example with two conditions.

{
"all": [
{
"fact": "Encryption",
"operator": "exist",
"value": "true"
},
{
"fact": "region",
"operator": "equals",
"value": "us-west-2"
}
]
}

Nested Properties

There can be an object or an array for the nested properties. The following sections showcases an example with the scenario and the JSON syntax.

Property Type: Object { }

If you would to evaluate a property of an object, you can use an additional key, "path".

For example, the following code block showcases a part of the AWS DBInstances JSON.

{
"MasterUserSecret": {
"SecretArn": "STRING",
"SecretStatus": "STRING",
"KmsKeyId": "STRING"
}
}

I would like the "KmsKeyId" of the "MasterUserSecret" to be equal to “xyz”:

{
"all": [
{
"fact": "MasterUserSecret",
"path": "KmsKeyId",
"operator": "equal",
"value": "xyz"
}
]
}

Property Type: Array [ ]

If the property is an array, you can create a nested condition in the value key of the parent property.

For example, this is a part of the AWS DBInstances JSON:

{
"dbInstanceSnapshots": [
{
"accountId": "STRING",
"Encrypted": "BOOLEAN",
"KmsKeyId": "STRING"
}
]
}

I would like to evaluate every dbInstanceSnapshots to be Encrypted: true.

  • Notice how the operator in the second level is "all". This is because I would like to evaluate every item within the array. Then the nested operator (or the third level operator) is "equal" so that I can verify if it is encrypted to be true.

{
"all": [
{
"fact": "dbInstanceSnapshots",
"operator": "all",
"value": {
"fact": "Encrypted",
"operator": "equal",
"value": true
}
}
]
}

Another scenario is if I would like every dbInstaneSnapshots to be Encrypted: true and KmsKeyId: 123.

{
"all": [
{
"fact": "dbInstanceSnapshots",
"operator": "all",
"value": {
"all" : [
{
"fact": "Encrypted",
"operator": "equal",
"value": true
},
{
"fact": "KmsKeyId",
"operator": "equal",
"value": "123"
}
]
}
}
]
}

Tags: Key-Value Pair

Here is how you can configure conditions in the advanced editor to evaluate tags by Key-Value Pair. The builder will only let you match by the Key. For "fact", select the Tags value that corresponds with that resource. Verify your information with the Resource guide.

{
"all": [
{
"fact": "TagList",
"operator": "all",
"value": {
"all": [
{
"fact": "Key",
"operator": "equal",
"value": "key"
},
{
"fact": "Value",
"operator": "equal",
"value": "123"
}
]
}
}
]
}
Did this answer your question?