MQTT Telemetry via Telegraf in NetCrunch
This topic explains how to collect system metrics published via MQTT, process them using Telegraf, and forward them to a NetCrunch Telemetry Node endpoint using JSON-based telemetry data.
Overview
MQTT is a lightweight publish/subscribe messaging protocol commonly used in IoT and distributed systems. Telegraf can subscribe to MQTT topics, parse incoming JSON messages, and forward them to a NetCrunch Telemetry Node via the HTTP output plugin.
How NetCrunch Supports MQTT Telemetry
NetCrunch receives MQTT-based telemetry through Telemetry Nodes, which accept data in JSON format and anchor incoming metrics or status values. Telemetry Nodes do not require network discovery and can receive data from distributed or isolated systems.
The endpoint, its URL shape and how it is authorized are described once in Monitoring with Telegraf. Everything below assumes a Telemetry Node already exists — see Telemetry Node.
Data Flow
- Metric Generation - Systems generate metrics using scripts, applications, or monitoring agents.
- MQTT Publishing - Metrics are published as JSON messages to MQTT broker topics.
- Telegraf Subscription - Telegraf subscribes to designated MQTT topics.
- Data Forwarding - Telegraf sends received messages to the NetCrunch Telemetry Node endpoint.
- NetCrunch Processing - Incoming data is stored as counters or alert statuses.
Telegraf Configuration
The primary configuration file is typically located at:
- Linux:
/etc/telegraf/telegraf.conf - Windows:
C:\Program Files\Telegraf\telegraf.conf
Basic Configuration
MQTT messages must be valid JSON for Telegraf to parse them correctly.
[agent] interval = "30s" flush_interval = "30s" debug = false quiet = true[[inputs.mqtt_consumer]] servers = ["tcp://localhost:1883"] topics = [ "linux/kernel/errors", "linux/fd/usage", "linux/systemd/failed", "linux/packages/health", "linux/security/entropy" ] data_format = "json" json_name_key = "measurement_name" tag_keys = ["hostname"]
[[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor01@node100/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json"
Configuration Parameters
Agent Section
interval- How frequently data is collectedflush_interval- How often data is forwardeddebug- Enables verbose debugging informationquiet- Suppresses non-error output
MQTT Consumer Input
servers- MQTT broker addresstopics- Subscribed MQTT topicsdata_format- Expected format (json)json_name_key- JSON field used as measurement nametag_keys- Fields extracted as tags
HTTP Output
url- NetCrunch Telemetry Node endpointmethod- Must be POSTdata_format- JSON payload formatheaders- HTTP headers
MQTT Message Format
Messages published to MQTT topics must be JSON objects containing relevant metadata and metric fields.
Required Fields
timestamp- ISO 8601 timestamphostname- System identifierMetric fields- Numeric or string values representing counters or statuses
Example Messages
Kernel Errors
{ "timestamp": "2025-10-29T15:09:08+01:00", "hostname": "server01.example.com", "kernel_errors_5min": 0 }
File Descriptor Usage
{ "timestamp": "2025-10-29T15:05:12+01:00", "hostname": "server01.example.com", "total_fd_count": 1471 }
Package Health Status
{ "timestamp": "2025-10-29T15:07:54+01:00", "hostname": "server01.example.com", "upgradable_packages": 1, "broken_packages": 0 }
System Entropy Level
{ "timestamp": "2025-10-29T15:09:08+01:00", "hostname": "server01.example.com", "entropy_available": 256 }
Failed Systemd Units
{ "timestamp": "2025-10-29T15:06:41+01:00", "hostname": "server01.example.com", "failed_units_count": 0 }
Use Cases
IoT Device Monitoring
Devices publish telemetry to an MQTT broker. Telegraf consumes the messages and sends them to NetCrunch for visualization and alerting.
Distributed System Metrics
Systems across remote networks publish metrics to centralized MQTT brokers. NetCrunch receives telemetry without requiring direct connectivity.
Custom Application Telemetry
Applications publish structured metrics to MQTT topics, avoiding the need to implement HTTP endpoints.
Edge Computing
Edge devices publish telemetry locally into an MQTT broker. Telegraf aggregates and forwards it to NetCrunch.
Multi-Tenant Monitoring
Topic structures and tag extraction allow routing metrics to separate Telemetry Nodes based on tenant or subsystem.
Summary
Using MQTT with Telegraf and NetCrunch provides a scalable and flexible telemetry pipeline. Publishers send JSON metrics to an MQTT broker, Telegraf subscribes to relevant topics, and telemetry is forwarded to NetCrunch using REST endpoints. This model supports IoT, distributed architectures, and custom monitoring scenarios without requiring SNMP or WMI.
- What Is a Node in NetCrunch?
This topic explains the definition of a Node in NetCrunch. It clarifies why a Node is treated as a service endpoint rather than a physical device, and how this distinction improves monitoring accuracy for modern infrastructure.
- NetCrunch Monitoring Objects
Everything NetCrunch monitors is an object with a state - nodes, interfaces, services, sensors, alerts, and the statuses calculated from them. Knowing which object you are looking at tells you what you can alert on, put on a dashboard, and roll up into a service status.
- - deleted - Understanding NetCrunch Data Formats
- Monitoring External Sources
How NetCrunch monitors data originating outside built-in collectors using telemetry, scripts, files, and external APIs.
- NetCrunch Native Data Formats
Native payload formats used by NetCrunch to ingest external monitoring data as counters, statuses, and contextual data objects using JSON, XML, and CSV.
- Telemetry in NetCrunch
Telemetry enables systems to push metrics and logs into NetCrunch without polling. This topic explains when to use telemetry and how NetCrunch supports it via Telemetry Nodes and the OTLP cloud gateway.
- Telemetry Node
A Telemetry Node is a NetCrunch node type for receiving metrics, statuses, and events from external systems via REST or OTLP. It anchors telemetry data for cloud, IoT, or custom systems, and replaces the older REST Receiver with a unified, event-capable design.
- Monitoring with Telegraf
Use Telegraf, the open-source metrics agent, to collect from systems NetCrunch does not poll directly and push the results into NetCrunch as ordinary counters and statuses.
- Linux Sysctl Filesystem Monitoring via Telegraf in NetCrunch
This topic explains how to monitor Linux kernel filesystem parameters using Telegraf and send collected metrics to NetCrunch Telemetry Nodes. The Linux Sysctl Filesystem input plugin reads values from the proc sys fs directory and forwards them to NetCrunch using the HTTP output plugin.
- SQL Server Monitoring via Telegraf in NetCrunch
This topic explains how to configure Telegraf to collect Microsoft SQL Server metrics and forward them to a NetCrunch Telemetry Node endpoint using JSON-based telemetry data. It covers SQL Server login setup, connection strings, Telegraf input configuration, and supported metric types.
- Azure Resource Monitoring using Telegraf in NetCrunch
This document describes how to configure Telegraf to collect metrics from various Azure resources (such as Virtual Machines, Storage Accounts, and Databases) and send them to NetCrunch via the Telemetry Node endpoint.