Filter a list with field selectors
Field selectors filter a list of Red Hat Edge Manager resources based on specific resource field values. They follow the same syntax, principles, and operators as Kubernetes Field and Label selectors, with additional operators available for more advanced search use cases.
Supported fields Copy linkLink copied!
Red Hat Edge Manager resources give a set of metadata fields that you can select.
Each resource supports the following metadata fields:
-
metadata.name -
metadata.owner -
metadata.creationTimestamp
To query labels, use Label Selectors for advanced and flexible label filtering.
For more information, see Labels and label selectors.
List of additional supported fields Copy linkLink copied!
In addition to the metadata fields, each resource has its own unique set of fields that you can select, offering further flexibility in filtering and selection based on resource-specific attributes.
The following table lists the fields supported for filtering for each resource kind:
| Kind | Fields |
|---|---|
| Certificate Signing Request |
|
| Device |
|
| Enrollment Request |
|
| Fleet |
|
| Repository |
|
| Resource Sync |
|
Fields discovery Copy linkLink copied!
Some Red Hat Edge Manager resources might expose additional supported fields. You can discover the supported fields by using flightctl with the --field-selector option. If you try to use an unsupported field, the error message lists the available supported fields.
See the following examples:
flightctl get device --field-selector='text'
Error: listing devices: 400, message: unknown or unsupported selector: unable to resolve selector name "text". Supported selectors are: [metadata.alias metadata.creationTimestamp metadata.name metadata.nameoralias metadata.owner status.applicationsSummary.status status.lastSeen status.summary.status status.updated.status]
The field text is not a valid field for filtering. The error message provides a list of supported fields that you can use with --field-selector for the Device resource.
You can then use one of the supported fields:
flightctl get devices --field-selector 'metadata.alias contains cluster'
The metadata.alias field is checked with the containment operator contains to see if it has the value cluster.
Examples
Example 1: Excluding a specific device by name
The following command filters out a specific device by its name:
flightctl get devices --field-selector 'metadata.name!=c3tkb18x9fw32fzx5l556n0p0dracwbl4uiojxu19g2'
Example 2: Filter by owner, labels, and creation timestamp
This command retrieves devices owned by Fleet/pos-fleet, located in the us region, and created in 2024:
flightctl get devices --field-selector 'metadata.owner=Fleet/pos-fleet, metadata.creationTimestamp >= 2024-01-01T00:00:00Z, metadata.creationTimestamp < //2025-01-01T00:00:00Z' -l 'region=us'
Example 3: Filter by Owner, Labels, and Device Status
This command retrieves devices owned by Fleet/pos-fleet, located in the us region, and with a status.updated.status of either Unknown or OutOfDate:
flightctl get devices --field-selector 'metadata.owner=Fleet/pos-fleet, status.updated.status in (Unknown, OutOfDate)' -l 'region=us'
Supported operators Copy linkLink copied!
Learn the operators and corresponding symbols you can use to construct sophisticated field selectors when querying or filtering Red Hat Edge Manager resources. This enables precise and flexible control over resource selection.
| Operator | Symbol | Description |
|---|---|---|
| Exists |
|
Checks if a field exists |
| DoesNotExist |
|
Checks if a field does not exist |
| Equals |
|
Checks if a field is equal to a value |
| DoubleEquals |
|
Another form of equality check |
| NotEquals |
|
Checks if a field is not equal to a value |
| GreaterThan |
|
Checks if a field is greater than a value |
| GreaterThanOrEquals |
|
Checks if a field is greater than or equal to a value |
| LessThan |
|
Checks if a field is less than a value |
| LessThanOrEquals |
|
Checks if a field is less than or equal to a value |
| In |
|
Checks if a field is within a list of values |
| NotIn |
|
Checks if a field is not in a list of values |
| Contains |
|
Checks if a field has a value |
| NotContains |
|
Checks if a field does not contain a value |
Operators usage by field type Copy linkLink copied!
Each field type supports a specific subset of operators:
| Field Type | Supported Operators | Value |
|---|---|---|
| String |
|
Text string |
| Timestamp |
|
RFC 3339 format |
| Number |
|
Number format |
| Boolean |
The list can only contain
|
Boolean format ( |
| Array |
Using |
Array element |