Skip to content

Add layout option to NATS output plugin #16558

@tulku

Description

@tulku

Use Case

Publish different fields to different subjects when using the NATS output plugin. This will allow NATS clients interested in some fields to subscribe individually while others can use wildcards to subscribe to many simultaneously.

This behavior could now be accomplished by adding one output plugin per field and using the filters to select what metrics are delivered to each plugin. However, this is only viable when managing a small number of fields.

Expected behavior

The NATS output plugin should have new configuration options. Maybe something like:

  • A new layout configuration (similar to the MQTT output plugin). This option would have one value that will retain the current plugin behavior, of a fixed subject for all metrics it receives, and a new value to select the new functionality.
  • The subject should be a template instead of a fixed string.

Given the following pseudo-configuration:

  • layout = fields
  • subject = {{ .Name }}.{{ .Field }}
  • data_format = influx

And the following line protocol metric as input:

sensors device=1 temperature=20,humidity=80 1234

The NATS output plugin should publish the following messages into the specified subjects:

subject: sensors.temperature
message: sensors device=1 temperature=20 1234

and

subject: sensors.humidity
message: sensors device=1 humidity=80 1234

Note: The plugin would need to split the metrics because the different fields are sent to specific subjects, copying all the extra information in the line protocol (name, tags, timestamp) on every output message. This is different from what the MQTT plugin does when using layout=fields

Actual behavior

Currently, the plugin can only publish messages to a specific subject. This means that to emulate the desired behavior we would need to add one output plugin per field name, which would be too much for our case.

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestRequests for new plugin and for new features to existing pluginshelp wantedRequest for community participation, code, contributionsize/m2-4 day effort

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions