Filters
Filters allow you to narrow down the applicability of a collector/check/track/campaign to a specific set of entities in the Software Catalog. Depending on the collector/check/track/campaign you are working on and the method that you choose to use to configure them - YAML or No-Code UI (NCUI) - there will be different syntax or options available to you. The following sections go over this in detail.
Check filter
You can add a filter either from a No-Code UI or from YAML file.
No-Code UI
When adding a check in No-Code UI one of the steps will allow you to choose the filters, and will show you the list of entities to which the filters will apply.
YAML
When adding a check in YAML you can do it as in the code snippet below.
To be able to easily see what entities your filter will apply to you can create a check in the No-Code UI and then export the YAML.
id: example_check_with_filter
rule:
all:
- factRef: catalog:default/entity_descriptor
path: $.metadata.description
operator: exists
value: true
ownerEntityRef: group:default/backstage
name: Example Check With Filter
description: This is a sample check with a check-level filter set.
filter:
catalog:
kind:
- component
spec.type:
- service
passedMessage: 'Pass: The entity has a description set in its metadata.'
failedMessage: 'Failed: The entity does not have a description set in its metadata.'
Learn more about check filters here
Track filters
You can add a filter either from a No-Code UI or from YAML file.
No-Code UI
When adding a track in No-Code UI one of the steps will allow you to choose the filters, and will show you the list of entities to which the filters will apply.
YAML
When adding a track in YAML you can do it as in the code snippet below.
To be able to easily see what entities your filter will apply to you can create a track in the No-Code UI and then export the YAML.
- id: test-certified
name: Test Certified
ownerEntityRef: group:default/example-owner
description: >
Improve quality and reliability of your software component by measuring the use of testing best practices.
documentationURL: https://www.backstage.io
filter:
catalog:
metadata.tags: java
levels:
- ordinal: 1
checks:
- id: github_actions_tests_passing
name: CI/CD Tests passing
description: >
The last tests run in GitHub Actions was successful.
Learn more about track filters here
Collector filter
You can add a filter either from a No-Code UI or from YAML file.
No-Code UI
When configuring a collector in No-Code UI one of the steps will allow you to choose the filters, and will show you the list of entities to which the filters will apply.
YAML
When adding a collector in YAML you can do it as in the code snippet below.
---
frequency:
cron: '0 * * * *'
collects:
- factName: branch_protections
type: BranchProtections
branch: master
filter:
- spec.lifecycle: 'production'
spec.type: 'website'
cache: false
Learn more about collector filters by picking the collector of your interest here. Then navigate to the filters subsection of that specific collector.
Campaign filter
You can add a filter either from a No-Code UI.
No-Code UI
When adding a campaign in No-Code UI one of the steps will allow you to choose the filters as well as you will see a list of entities to which it will apply.