Icon for NATSIcon for InfluxDB

NATS and InfluxDB Integration

Integrates withCurated

Overview

NATS and InfluxDB are complementary technologies commonly used together in IIoT stacks. NATS serves as the high-performance message bus collecting telemetry from devices and applications, while InfluxDB provides purpose-built time-series storage and analytics.

Integration Architecture

Sensors/Devices → [NATS] → Telegraf/NATS Consumer → [InfluxDB] → Grafana

Data Flow:

  1. Devices publish telemetry to NATS subjects (e.g., plant.line1.sensor.temperature)
  2. NATS fans out messages to multiple consumers
  3. Telegraf (with NATS input plugin) or custom consumers read from NATS
  4. Data is written to InfluxDB for storage
  5. Grafana queries InfluxDB for visualization

Use Cases

  • Real-time monitoring — Stream sensor data through NATS to InfluxDB for live dashboards
  • Alerting — Use NATS queue groups to distribute alerting workloads
  • Historical analysis — Persist time-series data with InfluxDB's retention policies
  • Edge-to-cloud — Deploy NATS at edge, replicate to central InfluxDB

Configuration

Telegraf NATS Input Plugin:

[[inputs.nats_consumer]]
  servers = ["nats://localhost:4222"]
  subjects = ["sensors.>"]
  queue_group = "telegraf"
  data_format = "json"

Alternative: Custom Consumer Write a NATS consumer using the official client library that batches writes to InfluxDB for higher throughput.

Tradeoffs & Considerations

  • Throughput — NATS can handle higher throughput than InfluxDB can ingest; consider batching
  • Schema — Define consistent subject hierarchies for easy routing
  • Retention — Use NATS JetStream for temporary buffering during InfluxDB maintenance
  • Alternatives — For simpler setups, Telegraf can receive MQTT directly without NATS