Background
Data Prepper pipelines currently do not support conditionals or routing. Thus all events in Data Prepper must flow through all sinks and processors in a pipeline. Many users require the ability to route events to different sinks and processors depending on the specific event.
The following diagram outlines a common scenario: Users need to route data to different sinks depending on some property of the event.

Proposal
This RFC introduces a concept of a router to Data Prepper. Pipeline authors can define named routes in the router. Data Prepper will apply routes to individual Events before sending them to Sinks.
This GitHub issue focuses on using routing to route sinks. See #522 RFC for a proposal for routing through a processor chain.
The following diagram outlines where the router will sit and what it will perform.

Design
Data Prepper will introduce a new router component to the pipeline. This is at the same level of the YAML as the prepper and sink. The router will run after the Processor chain and before the Sinks. Data Prepper would evaluate these routes directly before passing the Events into the sinks.
log-pipeline:
source:
http:
processor:
router:
- application-logs: '/log_type == "application"'
- http-logs: '/log_type == "apache"'
sink:
- opensearch:
hosts: [ "https://opensearch:9200" ]
index: application_logs
routes: [application-logs]
- opensearch:
hosts: [ "https://opensearch:9200" ]
index: http_logs
routes: [http-logs]
- opensearch:
hosts: [ "https://opensearch:9200" ]
index: all_logs
Any sink with the routes property will only accept Events which match at least one of the routes. In the example above, application-logs is a named route. Data Prepper will only route events with the application-logs route to the first opensearch sink.
By default, Data Prepper will route all Events to a sink which does not define a route. Thus, in the example above, all Events will go into the third opensearch sink.
Alternatives
See the comments below for alternatives.
Background
Data Prepper pipelines currently do not support conditionals or routing. Thus all events in Data Prepper must flow through all sinks and processors in a pipeline. Many users require the ability to route events to different sinks and processors depending on the specific event.
The following diagram outlines a common scenario: Users need to route data to different sinks depending on some property of the event.
Proposal
This RFC introduces a concept of a router to Data Prepper. Pipeline authors can define named routes in the router. Data Prepper will apply routes to individual Events before sending them to Sinks.
This GitHub issue focuses on using routing to route sinks. See #522 RFC for a proposal for routing through a processor chain.
The following diagram outlines where the router will sit and what it will perform.
Design
Data Prepper will introduce a new
routercomponent to the pipeline. This is at the same level of the YAML as theprepperandsink. The router will run after the Processor chain and before the Sinks. Data Prepper would evaluate these routes directly before passing the Events into the sinks.Any
sinkwith theroutesproperty will only accept Events which match at least one of the routes. In the example above,application-logsis a named route. Data Prepper will only route events with theapplication-logsroute to the firstopensearchsink.By default, Data Prepper will route all Events to a sink which does not define a route. Thus, in the example above, all Events will go into the third
opensearchsink.Alternatives
See the comments below for alternatives.