---
title: NATS
slug: telemetry-pipeline/teCq-nats
docTags: 
createdAt: 2025-04-21T00:52:38.551Z
---

## NATS Source

The NATS source enables reading observability data from subjects in a **NATS messaging system**. It is commonly used to ingest telemetry data published by applications, agents, or pipelines that rely on NATS as a transport layer.

This source operates in an **aggregator** role and supports **logs**, **metrics**, and **traces**. Message delivery follows a **best-effort** model and does not support acknowledgements.

## Configuration Overview

The NATS source connects to a NATS server, subscribes to one or more subjects, and decodes incoming messages into telemetry events. It supports multiple authentication mechanisms, flexible decoding strategies, optional framing, and JetStream integration.

## Connection Settings

### Required Fields

- **url** (string)
  &#x20;The NATS server URL to connect to.
  &#x20;If no port is specified, the default NATS port (4222) is used.&#x20;
- **connection\_name** (string)
  &#x20;A logical name assigned to the NATS connection for identification and observability.&#x20;
- **subject** (string)
  &#x20;The NATS subject from which messages are consumed.&#x20;

### Optional Fields

- **queue** (string)
  &#x20;The NATS queue group to join, enabling load-balanced consumption.&#x20;
- **subject\_key\_field** (string, default: subject)
  &#x20;The field name used to store the NATS subject in the event.&#x20;
- **subscriber\_capacity** (unsigned integer, default: 65536)
  &#x20;Buffer capacity of the underlying NATS subscriber.
  &#x20;When exceeded, incoming messages may be dropped.&#x20;

## Authentication (auth)

Defines how the source authenticates with the NATS server. The authentication strategy is selected using auth.strategy.

### Supported Strategies

- **credentials\_file** (JWT-based authentication)&#x20;
- **nkey** (NKey authentication)&#x20;
- **token** (Token-based authentication)&#x20;
- **user\_password** (Username and password authentication)&#x20;

### Strategy-Specific Fields

- **credentials\_file.path**
  &#x20;Path to the NATS credentials file.&#x20;
- **nkey.nkey**
  &#x20;Public NKey (conceptually equivalent to a username).&#x20;
- **nkey.seed**
  &#x20;Private seed (conceptually equivalent to a private key).&#x20;
- **token.value**
  &#x20;Authentication token.&#x20;
- **user\_password.user**
  &#x20;Username.&#x20;
- **user\_password.password**
  &#x20;Password.&#x20;

:::BlockQuote
TLS client certificate authentication is configured separately under tls.
:::

## Decoding Configuration (decoding)

Controls how raw message bytes are converted into events. Some decoders can automatically determine the output type (logs, metrics, or traces).

### Codec Selection

- **decoding.codec** (string, default: bytes)&#x20;

Supported codecs include:

- bytes&#x20;
- json&#x20;
- avro&#x20;
- gelf&#x20;
- influxdb&#x20;
- syslog&#x20;
- protobuf&#x20;
- otlp&#x20;
- native&#x20;
- native\_json&#x20;
- vrl&#x20;

Certain codecs (such as native, native\_json, and otlp) can emit **logs, metrics, and traces** directly.

### OTLP Decoding

When using the otlp codec, the decoder automatically detects the OTLP signal type.

- **decoding.signal\_types** (list of strings)
  &#x20;Signal types to attempt parsing, in priority order.
  &#x20;Defaults to logs, metrics, traces.&#x20;

### Codec-Specific Options

Each codec may define additional options, such as:

- **lossy decoding** (for JSON, GELF, InfluxDB, Syslog, Native JSON)
  &#x20;Controls whether invalid UTF-8 sequences are replaced or cause failures.&#x20;
- **schema and descriptor configuration** (for Avro and Protobuf)&#x20;
- **VRL decoding**
  &#x20;Executes a VRL program to transform raw bytes into structured events.&#x20;

## Framing Configuration (framing)

Defines how individual messages are separated from the raw byte stream before decoding.

### Supported Framing Methods

- bytes&#x20;
- character\_delimited&#x20;
- newline\_delimited&#x20;
- length\_delimited&#x20;
- varint\_length\_delimited&#x20;
- octet\_counting&#x20;
- chunked\_gelf&#x20;

Each framing method supports optional limits to protect against malformed or unbounded data, such as maximum frame length or timeout settings.

## JetStream Integration (jetstream)

Enables consumption from **NATS JetStream** using a pull-based durable consumer.

### Required Fields

- **jetstream.stream**
  &#x20;Name of the JetStream stream.&#x20;
- **jetstream.consumer**
  &#x20;Name of the durable consumer.&#x20;

### Optional Fields

- **batch\_config.batch**
  &#x20;Maximum number of messages per pull request.&#x20;
- **batch\_config.max\_bytes**
  &#x20;Maximum total byte size per batch.&#x20;

JetStream defaults are aligned with the async-nats client behavior.

## TLS Configuration (tls)

Configures TLS for connections to the NATS server.

### Supported Options

- **enabled**&#x20;
- **crt\_file**&#x20;
- **key\_file**&#x20;
- **key\_pass**&#x20;
- **ca\_file**&#x20;
- **alpn\_protocols**&#x20;
- **verify\_certificate**&#x20;
- **verify\_hostname**&#x20;
- **server\_name**&#x20;

:::BlockQuote
Disabling certificate or hostname verification is strongly discouraged unless the security implications are fully understood.
:::

## Output

The default output stream of the NATS source is exposed using the component’s ID and can be connected to downstream transforms and sinks.

### Event Types

- **Logs**&#x20;
- **Metrics**&#x20;
- **Traces**&#x20;

### Log Event Fields

- **message** (string)
  &#x20;Raw payload from the NATS message.&#x20;
- **subject** (string)
  &#x20;NATS subject the message was received from.&#x20;
- **source\_type** (string)
  &#x20;Always set to nats.
