Skip to content

Kafka: support templated topic name #38888

Open
@axw

Description

@axw

Component(s)

exporter/kafka

Is your feature request related to a problem? Please describe.

The kafkaexporter component can be configured in various ways to determine the topic to which messages are published:

This is complex, and there are problems with each of these options:

Describe the solution you'd like

Replace all of these with a templated topic name, e.g. otlp_{signal_record_type}s where "signal_type" expands to "log", "span", or "metric"; variable name is just for illustration. The {...} bit would be treated as an expression, e.g. using OTTL. So you could for example include:

  • client metadata (for multi-tenancy): topic: {request["x-tenant-id"]}.whatever
  • resource attributes: topic: {resource.attributes["service.name"]}-logs

See also #35432 (comment)

Assuming we use OTTL for the template expressions, then we may be able to rely on OTTL context inference to decide when to determine the topic: per request, resource, scope, record, etc. Otherwise, we could limit determining the topic to the resource level.

We should also support a templated topic for kafkareceiver to resolve #32735, but in that case the only expression that would make sense is the signal type. We'll need to consider how the templating syntax interacts with support for topic regular expressions, which the receiver should also ideally support.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions