Filters
Use filters to receive only the notifications that match specific criteria, such as:
- "Send new deployment notifications to Slack channel #my-org-deployments"
- "Notify me when scopes are deleted or stopped"
- And more...
How to create filters
The filters
field supports the use of MongoDB query syntax, allowing you to create complex expressions and conditions.
Here's a list of the most common operators:
Operator | Description |
---|---|
$and | Joins query clauses with a logical AND. Returns results that match all the conditions. |
$not | Inverts the effect of a query predicate. Returns results that do not match the condition. |
$nor | Joins clauses with a logical NOR. Returns results that fail to match all conditions. |
$or | Joins clauses with a logical OR. Returns results that match any condition. |
info
Refer to MongoDB operators for the full reference.
Filter examples
Here are some examples on how you can set up these criteria, based on the notification source.
Approval examples
Set one slack channel for each namespace
"source": ["approval"],
...
"filters": {
“details.namespace.slug”: “the-namespace-slug-of-my-team”
}
Set one channel for deployments approval
"source": ["approval"],
...
"filters": {
"action": "deployment:create"
}
Set one channel for deleted or stopped scopes
"source": ["approval"],
...
"filters": {
"$or": [{"action": "scope:stop"}, {"action": "scope:delete"}]
}
Set a channel for all approvals but filter out deployment creates
"source": ["approval"],
...
"filters": {
"action": { "$ne": "deployment:create" }
}
Service examples
Set a channel for each service specification
"source": ["service"],
...
"filters": {
"service.specification.slug": "my-service-specification-slug"
}
Set channels for each development and production applications
Filter notifications for the application you're using to craft and test your services.
"source": ["service"],
...
"filters": {
"tags.application_id": "111"
}
Filter notifications for the application used for production.
"source": ["service"],
...
"filters": {
"tags.application_id": { "$ne": "222" }
}
Audit examples
Set a channel to audit activity on applications
"source": ["audit"],
...
"filters": {
"entity": "application"
}
Set a channel for when an application is created successfully
"source": ["audit"],
...
"filters": {
"entity": "application",
"entity_data.status": "active"
}
Set a channel to receive activity for each account
"source": ["audit"],
...
"filters": {
"entity_context.account_id": 333
}