Searching & Filtering
Guardrails' powerful discovery mechanism crawls your infrastructure and builds a structured, hierarchical representation of your assets in the Guardrails CMDB.
Guardrails provides a powerful advanced query syntax to search and query the CMDB. This filter syntax can be used to search and filter results in the Guardrails console UI as well as in GraphQL queries, providing a single, consistent interface for querying the CMDB.
[!NOTE] This guide introduces the search and filter concepts. For the complete syntax reference, see the Filter Reference Documentation.
Basic Searching and Filtering
Guardrails' basic search capability is intuitive. Simply enter text and Guardrails will perform a case-insensitive search against all the properties of all objects.
If multiple search terms are specified, Guardrails will search for items that contain both terms. For example, a search for bucket demo will return all resources that contain both bucket AND demo.
The filter syntax can be used across the Guardrails console in any search or filter field. These filters are implicitly scoped to the list type. A filter on the Resources page only searches resources, the Controls list only searches controls, etc.
You can also drill into a specific resource and search from there, restricting results to only child resources of the currently selected resource.
The GraphQL API uses the exact same filter syntax for list queries (resources, controls, notifications, etc).
Advanced Full Text Search
A filter can be negated with the - or ! character. For example, !demo or -demo finds resources that do not contain demo.
The search keyword may be used to specify "OR" conditions using a comma-separated list. For example, search:bucket,demo finds resources that contain either bucket OR demo.
Regular expressions are also supported, delimited with forward slashes. Note that regular expressions search the title only. For example, /^demo/ finds resources whose title begins with demo.
| Aim | Filter |
|---|---|
| Require foo | foo |
| Exclude foo | -foo or !foo |
| Require "foo" and "bar" | foo bar |
| Require "foo bar" (exact phrase) | "foo bar" |
| Exclude "foo bar" | !"foo bar" |
| Require foo or bar | search:foo,bar |
| Title starts with "foo" | /^foo/ |
| Title contains "foo", case insensitive | /foo/i |
| Title does not contain "foo" | !/foo/i |
Filtering on Specific Properties
Guardrails allows searching and filtering on specific properties of an object. The general format is: {property}:{operator}{value}
- The
{property}may be a standard Guardrails property or any field using the$.syntax. - The
{operator}depends on the data type: - The
{operator}is optional. The default behavior depends on the data type.
A condition can be negated by preceding it with ! or -. Multiple values can be joined with a comma for "OR" conditions. Multiple whitespace-separated conditions are joined as "AND" conditions.
Scoping with Levels
Many Guardrails lists display resources from multiple levels of the resource hierarchy. Use a levels filter to specify the scope of your search.
| Aim | Filter |
|---|---|
| Self only | level:self |
| Descendants only | level:descendant |
| Immediate children only | level:children |
| Ancestors only | level:ancestor |
| Self or descendants | level:self,descendant |
| Self or descendants (alternate) | level:all |
Examples
Resource Filters
| Aim | Filter |
|---|---|
| AWS account 876515858155 | resource:arn:aws:::876515858155 level:self |
| Resources in AWS account 876515858155 | resource:arn:aws:::876515858155 level:descendant |
| Resources with a "department" tag of "sales" | tags:department=/^sales$/i |
| Resources created in the last week | createTimestamp:>T-7d |
| Resources created or updated in the last 15 minutes | timestamp:>T-15m |
| EC2 Instances with private IP in 172.31.6.0/24 | resourceType:instance $.PrivateIpAddress:<172.31.6.0/24 |
| Volumes larger than 1000MB | resourceType:volume $.Size:>=1000 |
| Unattached volumes | resourceType:volume $.Attachments.*.State:!attached |
| All compute and storage resources | resourceCategory:compute,storage |
Policy Settings
| Aim | Filter |
|---|---|
| Settings that are orphaned | is:orphan |
| Settings that are exceptions | is:exception |
| Settings expiring in the next week | validToTimestamp:<T+7d,>now sort:validToTimestamp |
| Settings created/updated in the last day | timestamp:>T-1d sort:-timestamp |
Policy Values
| Aim | Filter |
|---|---|
| Policy values set to 'Check: Enabled' | value:'Check: Enabled' |
| Policy values for resources tagged "sales" | tags:department=/^sales$/i |
| Policy values not in OK state | state:-ok |
| Policy values for CIS policy types | policyType:cis |
Controls
| Aim | Filter |
|---|---|
| Controls in alarm or error | state:alarm,error |
| Approved controls for any bucket | resourceType:bucket controlType:approved |
| All alarms in the last hour | state:alarm timestamp:>T-1h |
| All storage-related tag controls | resourceCategory:storage controlCategory:tags |
| All CIS controls | controlCategory:cis |
Notifications
| Aim | Filter |
|---|---|
| Resource notifications, newest first | notificationType:resource sort:-timestamp |
| Recent deletion notifications | notificationType:resourceDeleted,policySettingDeleted,controlDeleted sort:-timestamp limit:100 |
| Recent permissions activity | notificationType:activeGrant,grant sort:-timestamp |
| Notifications for a specific user | actorIdentityId:162674901433086 |
Further Reading
See the Filter Reference Documentation for detailed information, including filters for: