Build filtered views in the web UI
The Sensu web UI includes basic filters you can use to build customized views of your Sensu resources. Sensu also supports advanced web UI filtering based on a wider range of resource attributes and custom labels as a commercial feature.
When you apply a filter to a web UI page, it creates a unique link for the filtered page. You can bookmark these links and share your favorite filter combinations.
Basic filters
Sensu includes these basic filters:
- Events page: filter by entity, check, status, and silenced/unsilenced.
- Entities page: filter by entity class and subscription.
- Checks page: filter by subscription and published/unpublished.
- Handlers page: filter by handler type.
- Filters page: filter by action.
- Silences page: filter by check and subscription.
You can also sort events and silences using the SORT dropdown menu:
- Events page: sort by last OK, severity, newest, and oldest.
- Silences page: sort by start date.
Advanced filters
COMMERCIAL FEATURE: Access advanced filtering in the packaged Sensu Go distribution. For more information, see Get started with commercial features.
Sensu supports advanced web UI filtering using a wider range of attributes, including custom labels. You can use the same methods, selectors, and examples for web UI filtering as for API response filtering, with some syntax differences.
Create basic web UI filters
If you are using the basic web UI filters, you can create your filter just by clicking in the filter bar at the top of the web UI page:
- In the web UI, open the page of resources you want to filter.
- Click in the filter bar at the top of the web UI page.
- Select the attribute you want to filter for from the dropdown list of options.
- Click in the filter bar again and select the filter to apply.
- Press Return/Enter.
NOTE: You do not need to specify a resource type in web UI filtering because you must navigate to the resource page before you construct the filter.
Create web UI filters based on label selectors or field selectors
To filter resources based on label selectors or field selectors, you’ll write a brief filter statement. The filter statement construction is slightly different for different operators, but the standard web UI filtering syntax is:
SELECTOR:FILTER_STATEMENT
To write a web UI filter command:
- Replace
SELECTOR
with the selector you want to use:labelSelector
orfieldSelector
. - Replace
FILTER_STATEMENT
with the filter to apply.
The examples demonstrate how to construct web UI filter statements for different operators and specific purposes.
Web UI-specific syntax
Space after the colon
Web UI filtering statements will work with no space or a single space after the colon.
For example, this filter will return all events for entities with the linux
subscription:
fieldSelector:linux in event.entity.subscriptions
And this filter will work the same way:
fieldSelector: linux in event.entity.subscriptions
Values that begin with a number or include special characters
If you are filtering for a value that begins with a number, place the value in single or double quotes:
fieldSelector:entity.name == '1b04994n'
fieldSelector:entity.name == "1b04994n"
Likewise, to use a label or field selector with string values that include special characters like hyphens and underscores, place the value in single or double quotes:
labelSelector:region == 'us-west-1'
labelSelector:region == "us-west-1"
Operators quick reference
Web UI filtering supports two equality-based operators, two set-based operators, one substring matching operator, and one logical operator.
operator | description | example |
---|---|---|
== |
Equality | check.publish == true |
!= |
Inequality | check.namespace != "default" |
in |
Included in | linux in check.subscriptions |
notin |
Not included in | slack notin check.handlers |
matches |
Substring matching | check.name matches "linux-" |
&& |
Logical AND | check.publish == true && slack in check.handlers |
For details about operators, see API response filtering operators.
Examples
Filter with label selectors
To filter resources using custom labels (in this example, to display only resources with the type
label set to server
:
labelSelector:type == server
To filter for entities that are labeled for any region in the US (e.g. us-east-1
, us-west-1
, and so on):
labelSelector:region matches "us"
Filter with field selectors
To filter resources using specific resource attributes (in this example, to display only events at 2
(CRITICAL) status):
fieldSelector:event.check.status == "2"
On the Events page, to display only events for checks with the subscription webserver
:
fieldSelector:webserver in event.check.subscriptions
On the Checks page, to display only checks that use the slack
handler:
fieldSelector:slack in check.handlers
Use the logical AND operator
To use the logical AND operator (&&
) to return checks that include a linux
subscription and the slack
handler:
fieldSelector:linux in check.subscriptions && slack in check.handlers
Combine label and field selectors
To combine labelSelector
and fieldSelector
filters, create the filters separately.
For example, to return resources with the region
label set to us-west-1
that also use the slack
handler:
-
Create the
labelSelector
filter in the filter bar and press Return/Enter.labelSelector:region == "us-west-1"
-
Add the
fieldSelector
filter in the filter bar after thelabelSelector
filter and press Return/Enter again.fieldSelector:slack in check.handlers
Save a filtered search
COMMERCIAL FEATURE: Access saved filtered searches in the packaged Sensu Go distribution. For more information, see Get started with commercial features.
To save a filtered search:
- Create a web UI filter.
- Click the save icon at the right side of the filter bar:
- Click Save this search.
- Type the name you want to use for the saved search.
- Press Return/Enter.
Sensu saves your filtered searches to etcd in a namespaced resource named searches
.
To recall a saved filtered search, a Sensu user must be assigned to a role that includes permissions for both the searches
resource and the namespace where you save the search.
The role-based access control (RBAC) reference includes example workflows that demonstrate how to configure a user’s roles and role bindings to include full permissions for namespaced resources, including saved searches.
Recall a saved filtered search
To recall a saved search, click the save icon in the filter bar and select the name of the search you want to recall.
You can combine an existing saved search with a new filter to create a new saved search. To do this, recall a saved search, add the new filter in the filter bar, and save the combination as a new saved search.
Delete a saved filtered search
To delete a saved search:
- Click the save icon in the filter bar:
- Click the delete icon next to the search you want to delete: