Encodes events to JSON or NDJSON format.

JSON Encoder

Encodes Arrow RecordBatches to JSON or newline-delimited JSON (NDJSON) format.

Configuration

FieldTypeRequiredDefaultDescription
codecstringyesMust be "json"
as_arraybooleannofalseIf true, output JSON array. If false, output NDJSON.

Example

sinks:
  my_http:
    type: http
    uri: http://example.com/events
    encoding:
      codec: json
      as_array: false  # NDJSON format

Output Formats

NDJSON (default)

One JSON object per line:

{"timestamp": "2024-01-15T10:30:00Z", "level": "info", "message": "Event 1"}
{"timestamp": "2024-01-15T10:30:01Z", "level": "warn", "message": "Event 2"}

JSON Array

Single JSON array containing all objects:

[
  {"timestamp": "2024-01-15T10:30:00Z", "level": "info", "message": "Event 1"},
  {"timestamp": "2024-01-15T10:30:01Z", "level": "warn", "message": "Event 2"}
]

When to Use

  • HTTP webhooks - Most APIs accept JSON
  • Logging systems - ELK, Splunk, Datadog
  • Debugging - Human-readable output
  • Message queues - Kafka, SQS with JSON payloads