The Carbon Black Cloud console provides some optional steps for creating and validating JSONPath criteria.
To build a correct JSONPath selector, you can enter a sample resource configuration or import the configuration of an already deployed resource in your Kubernetes environment. Based on this configuration, the Carbon Black Cloud console displays a preview of the selector's result; you can then build the selector.
Procedure
- On the left navigation pane, click .
- Click the Rules tab.
- Click Add Rule.
- Define the rule.
- Enter a unique custom rule name and a description.
- Select JSONPath, methods, values as the rule criteria.
- Click Next.
- Optionally enter the Resource kind from the dropdown menu. The default value is Any.
- Click Import to open an existing resource file from your Kubernetes environment. You can also copy/paste your content into the Sample resource JSON text box.
The resource file or copied content displays in the
Sample resource JSON text box to the left of the page.
- In JSONPath, enter a string (that you can copy from the displayed JSON file), and click the icon to the right of the text box.
- Enter a Method from the dropdown menu and type in a Value.
- Preview your selection in the Results for JSONPath area on the right of the page. If the string you entered is not returning any resources, a message displays to that effect. If you see a number, for example,
[1]
, there is one matching resource.
- Click Next.
- On the Confirm Rule page, review the summary of the rule criteria and the matching Kubernetes resources and click Save.
The custom rule is added to the Rules page. To review its details, click the arrow
icon at the right of the rule.