#294730·kibana

[Streams] Build the routing condition UI

Author: Kerry350Created Oct 1, 2026Updated Oct 1, 2026
LabelsFeature:StreamsTeam:streams-ui

What?

Build the condition authoring UI for the new Streams unit-config routing model. Users should still pick a field, an operator such as equals, and a value — the same interaction as the current Streamlang condition editor — but the value persisted on a route is an OTTL boolean expression string (when), not a Streamlang condition object.

This is the routing when field only. Wired Streams keeps its Streamlang where conditions.

Why?

Routing condition language replaced Streamlang predicates with OTTL. In pipeline.schema.yaml, route.when is type: string. streams-transpiler validates that string with the OTTL grammar and copies it unchanged into the OpenTelemetry routing connector condition. It does not accept { field, eq } and it does not rewrite operators.

The current editor cannot produce that string. It is built on the Streamlang Condition type:

  • Schema and operators: x-pack/platform/packages/shared/kbn-streamlang/types/conditions.ts
  • Form: x-pack/platform/plugins/shared/streams_app/public/components/stream_management/data_management/shared/condition_editor.tsx
  • Operator dropdown (including the UI-only "equals true" / "equals false" shorthands): .../shared/operator_selector.tsx
  • Read-only rendering: .../shared/condition_display.tsx
  • Routing wrapper: .../stream_detail_routing/routing_condition_editor.tsx

Those components should be the UX reference. Do not change what Wired Streams persists.

Target shape

A route in the unit config looks like this:

yaml
- when: 'body["event.dataset"] == "nginx.access"'
  destinations: [es-nginx]

- when: 'resource.attributes["env"] == "prod" and log.severity_number >= SEVERITY_NUMBER_WARN'
  telemetry: [logs]
  destinations: [alerts]

# Catch-all. Omit when. Do not write when: "true".
- destinations: [es-generic]

The friendly form is a UI model (field, operator, value, and/or/not groups). Serialize it to when on save, and parse a when string back into that form when the expression is one the form can represent. Expressions the form cannot represent (converter calls, mixed contexts, parenthesized mixes of and/or that the form did not produce) open in a raw OTTL editor, the same way isConditionEditableInUi falls back to YAML today.

when: "true" is valid OTTL but it is not the catch-all. The transpiler only treats a missing when as the routing-connector default pipeline. An empty string fails CheckCondition.

Operator mapping

Current Streamlang operator OTTL when
eq / neq == / !=
lt / lte / gt / gte < / <= / > / >=
UI shorthand "equals true/false", "not equals true/false" == true / == false / != true / != false
exists: true / exists: false path != nil / path == nil
range one comparison per bound, joined with and (path >= lo and path < hi, using the bound that was set)
and / or / not and / or / prefix not (...)
always omit when
contains / startsWith / endsWith no operator. Use IsMatch(path, "pattern") only if the user text is escaped as a literal. These are grammar-valid (IsMatch(body, "^error:") is what the transpiler tests accept) but they are regex, not substring operators.
includes no OTTL equivalent. Leave it out of this editor.
never do not emit the route. Do not write when: false.

Quote OTTL string literals with double quotes and escape " and \. Numbers and booleans stay unquoted. YAML-quote the whole when value when it contains double quotes, as the spec examples do.

Field paths

The old editor writes a bare document field such as event.dataset. OTTL paths depend on the signal and where the field lives. The form has to capture that; a bare dotted field name is not valid.

What the user is matching Expression, inside the inferred context
Docs / ECS field body["event.dataset"] (dotted ECS keys are flat keys on the log body)
Record attribute (logs, spans, datapoints) attributes["key"]
Resource attribute resource.attributes["key"], or context: resource plus bare attributes["key"]
Fully qualified equivalent log.body["event.dataset"] is valid and equivalent for docs

Default context is inferred from the signal: log for logs and docs, span for traces, datapoint for metrics. Set the route context field only when bare paths must resolve against something else. Allowed values are record, resource, log, span, metric, datapoint, profile. record is the signal-adaptive shorthand; the transpiler resolves it before emit, so the collector never sees the word record.

If one expression touches two contexts, qualify the record side: resource.attributes["env"] == "prod" and log.attributes["status"] == "active". A prefix has to be valid for every signal the route applies to. resource is valid on all signals; span is not valid on a logs route.

Validation

Syntax is whatever streams-transpiler accepts (OTTL grammar at collector-contrib v0.158.0): comparisons == != > >= < <=, and / or / not, literals, nil, and boolean converters such as IsMatch. Semantic checks (bad context for the signal, profiles) happen in the same compile. Per the UI validation decision, full OTTL validation is button-gated through the config distributor. Do not add a browser OTTL parser for per-keystroke checks. The form can still reject an incomplete row locally (missing field or value).

Profiles cannot use a conditional route to destinations. The routing connector does not carry profiles (E026_PROFILES_ROUTING_UNSUPPORTED). Do not offer a when clause on a profiles route that targets destinations.

Out of scope

  • Wired / classic Streams routing. Those routes stay Streamlang objects compiled to Painless.
  • Changing streams-spec or streams-transpiler. when stays a string.
  • Transform-processor conditions. Same language, separate editor. A shared serializer is fine later; this issue is routing.
  • Live OTTL syntax highlighting or per-keystroke compile.
  • The includes operator.

Acceptance criteria

Happy path

  • A routing rule edited in the friendly form is saved as a when string, not a Streamlang object.
  • equals, not equals, less than, less than or equals, greater than, greater than or equals, exists, in range, and, or, and not round-trip through the form for string, number, and boolean values.
  • The boolean shorthands persist as == true, == false, != true, and != false.
  • A catch-all rule omits when. Reloading that rule shows the same "match everything" state the current editor shows for { always: {} }.
  • Docs fields serialize as body["<field>"]. Record attributes serialize as attributes["<field>"]. Resource attributes serialize as resource.attributes["<field>"] unless the route sets context: resource.
  • A when string the form can represent reopens in the friendly editor. A string it cannot represent opens in a raw editor and is saved unchanged.

Edge cases

  • An incomplete row cannot be saved. An empty when: "" is never written.
  • String values that contain quotes or backslashes survive a save/load round-trip.
  • A route scoped to profiles does not offer a condition when it targets destinations.
  • contains, startsWith, and endsWith either serialize through escaped IsMatch and parse back to the same operator, or they are absent from the dropdown. They must not be written as substring operators (contains is not valid OTTL).
  • includes is not offered.

Deployment

  • Wired Streams routing still loads and saves Streamlang where conditions. This change does not alter that API or UI.

References