This is a cache of https://docs.openshift.com/serverless/1.29/eventing/triggers/filter-triggers-cli.html. It is a snapshot of the page at 2024-11-27T17:09:18.480+0000.
Filtering triggers from the command line - Triggers | Eventing | Red Hat OpenShift Serverless 1.29
×

Using the Knative (kn) cli to filter events by using triggers provides a streamlined and intuitive user interface. You can use the kn trigger create command, along with the appropriate flags, to filter events by using triggers.

Filtering events with triggers by using the Knative cli

In the following trigger example, only events with the attribute type: dev.knative.samples.helloworld are sent to the event sink:

$ kn trigger create <trigger_name> --broker <broker_name> --filter type=dev.knative.samples.helloworld --sink ksvc:<service_name>

You can also filter events by using multiple attributes. The following example shows how to filter events using the type, source, and extension attributes:

$ kn trigger create <trigger_name> --broker <broker_name> --sink ksvc:<service_name> \
--filter type=dev.knative.samples.helloworld \
--filter source=dev.knative.samples/helloworldsource \
--filter myextension=my-extension-value