Skip to content

New component: NATS as a Receiver and Exporter #39540

Open
@yeongjonglim

Description

@yeongjonglim

The purpose and use-cases of the new component

NATS is a common tool being deployed as part of an IoT solution thanks to its simplicity to deploy in edge location. Usually the edge location would contain other components that are worth monitoring (for all traces, metrics and logs). On top of that, NATS support data replication from edge to cloud making it a great candidate to stream telemetry data over internet reliably. Here I would like to propose to have a component which export OTLP data to NATS and a receiver to consume the OTLP data from NATS.

Example configuration for the component

receivers:
  nats:
    server_url: nats://localhost:4222
    tls:
      insecure: false
      ca_file: server.crt
      cert_file: client.crt
      key_file: client.key
      min_version: "1.1"
      max_version: "1.2"
    logs:
      subject: telemetry.logs
      encoding: otlp_proto
    metrics:
      subject: telemetry.metrics
      encoding: otlp_proto
    traces:
      subject: telemetry.traces
      encoding: otlp_json
    auth:
      # Option 1: Basic auth
      username: ${env:NATS_USERNAME}
      password: ${env:NATS_PASSWORD}
      # Option 2: Token-based auth
      token: ${env:NATS_TOKEN}
      # Option 3: TLS cert-based auth
      tls:
        cert_file: /etc/otel/certs/client-cert.pem
        key_file: /etc/otel/certs/client-key.pem
        ca_file: /etc/otel/certs/ca.pem
      # Option 4: NKey auth
      nkey: ${env:NATS_NKEY}
      # Option 5: JWT auth
      jwt: {env:NATS_JWT}

exporters:
  nats:
    server_url: nats://localhost:4222
    tls:
      insecure: false
      ca_file: server.crt
      cert_file: client.crt
      key_file: client.key
      min_version: "1.1"
      max_version: "1.2"
    logs:
      subject: telemetry.logs
      encoding: otlp_proto
    metrics:
      subject: telemetry.metrics
      encoding: otlp_proto
    traces:
      subject: telemetry.traces
      encoding: otlp_json
    auth:
      # Option 1: Basic auth
      username: ${env:NATS_USERNAME}
      password: ${env:NATS_PASSWORD}
      # Option 2: Token-based auth
      token: ${env:NATS_TOKEN}
      # Option 3: TLS cert-based auth
      tls:
        cert_file: /etc/otel/certs/client-cert.pem
        key_file: /etc/otel/certs/client-key.pem
        ca_file: /etc/otel/certs/ca.pem
      # Option 4: NKey auth
      nkey: ${env:NATS_NKEY}
      # Option 5: JWT auth
      jwt: {env:NATS_JWT}

processors:
  resource:
    attributes:
      - key: edge_device
        value: junction_123
        action: upsert

service:
  pipelines:
    metrics:
      receivers: [nats]
      processors: [resource]
      exporters: [nats]

Telemetry data types supported

traces, metrics and logs

Code Owner(s)

Looking for a code owner

Sponsor (optional)

Looking for a sponsor — open to guidance from maintainers or anyone involved with NATS

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Sponsor NeededNew component seeking sponsorneeds triageNew item requiring triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions