Route events to a Knative Service

Updated at:

Filter events by using event rules and route them to a Knative Service. This example uses a custom event to demonstrate the end-to-end workflow.

Prerequisites

Step 1: Add a custom event source

  1. Log on to the EventBridge console. In the left navigation pane, click Event Buses.
  2. In the top navigation bar, select a region. On the Event Buses page, click the target custom event bus.
  3. In the left navigation pane, click Event Sources, and then click Add Event Source.
  4. In the Add Custom Event Source panel, enter a Name and Description. For Event Provider, select Event Provider, and then click OK.

Step 2: Create an event rule

Important

The target service and the event rule must be in the same region.

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.

  2. In the top navigation bar, select a region. On the Event Buses page, click the name of the event bus that you want to manage.

  3. In the left-side navigation pane, click Event Rules. On the page that appears, click Create Rule.

  4. In the Create Rule panel, complete the following steps and then click Create.

    1. On the Configure Basic Info tab, enter a Name and Description for the rule, and then click Next Step.

    2. On the Configure Event Pattern tab, set Event Source Type to Custom Event Source, select the event source that you created, and then click Next Step.

    3. On the Configure Targets tab, configure the following parameters and click Create.

      Parameter

      Example

      Description

      Service Type

      Knative Service

      Select Knative Service from the drop-down list.

      Gateway

      alb-******

      Specify the gateway that you selected when deploying the Knative Service.

      Host

      ******.example.com

      The domain name associated with the Knative Service. You can use either the default or a custom domain name.

      Body

      Complete Event

      Event transformation supports four modes. For details, see event transformation.

      • Complete Event

      • Partial Event

      • Fixed Value

      • Template

      Maximum Concurrency

      22

      The maximum number of concurrent requests.

      Network Type

      Internet

      Supported network types:

Step 3: Publish an event

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.

  2. In the top navigation bar, select a region.
  3. On the Event Buses page, find the target event bus and click Publish Event in the Operations column.

    Note

    You can publish events from the console only for custom event buses.

  4. In the Publish Event to Custom Event Bus panel, select the custom event source that you created from the Custom Event Source drop-down list, enter the event content in the Event Body code editor, and then click Confirm.

    Note
    • For event parameter specifications, see Event structure.

    • The event ID is automatically copied after you click Confirm.

Verification

  1. Go to the Overview page of the target event bus.

  2. In the left-side navigation pane, click Event Tracking, and then click the Query By Event ID tab.

  3. Paste the event ID into the Event ID field and then click Query.

  4. In the Operations column for the target event, click Event Trace to verify its delivery status.

    In the Event Trace details panel, the Event Delivery section shows that the delivery status for the Knative rule is Succeeded and the response is [200], response: Http Status:200,Msg:Hello World!. This confirms that the event was delivered to the Knative Service.