Skip to content

Data Processing ​

EMQX Neuron includes a stream processing engine that filters, converts, aggregates, and evaluates alarms before data leaves the edge.

Data processing flow: collected points enter through the Neuron data source, alongside other sources such as MQTT, HTTP, SQL databases, files, and video streams; data passes through source, rule, and sink, and is written out to IoT platforms and message queues, databases and time-series databases, and object storage and files; the dashed line shows rule results written back to devices through a Neuron action

When to use it ​

Southbound data can be published directly by a northbound application without passing through data processing. Process it through a rule first when:

  • The polling rate far exceeds what the business needs. Polling every 100 ms catches transients, but a report only needs a per-minute average. Aggregating over a time window before publishing cuts volume by two orders of magnitude.
  • Values barely move in steady state. During normal operation tag values are nearly constant. A conditional filter publishes only when a value moves beyond a threshold.
  • Alarms need sub-second response. Keeping the decision at the edge avoids a cloud round trip and keeps working while the link is down.
  • Units or field names need normalizing before publishing. Doing it once at the edge beats doing it in every downstream system.

Both paths can run side by side. For selection guidance, see Northbound Applications · Feed Analytics and Edge Computing.

Reading order ​

  1. Your First Rule: bring collected data in, transform it with one SQL statement, and publish to MQTT
  2. Source: define where data comes from, used as a stream or a table in rules
  3. Rules: write SQL, add actions, and debug
  4. Sink: where rule results go

Connecting to the collection module ​

Data processing and the collection module are linked in both directions. These two connectors are the ones used most:

DirectionWhat to useNotes
Collection → rulesNeuron sourceThe northbound Rules Engine Application feeds subscribed collection groups into the neuronStream stream. The application exists by default — just add a subscription. See Rules Engine Application
Rules → devicesNeuron sinkRule results are written back to devices through southbound drivers, closing a collect → decide → control loop at the edge

Sources ​

A source defines how to connect to an external system. Creating one only registers a logical definition; data flows only once a rule that references it starts. The same definition can be used in the FROM clause of many rules.

In a rule, a source is used either as a stream or a table: a stream triggers computation whenever data arrives; a table represents the current state of a stream for batch processing, and comes in scan and lookup forms.

Decoding is set with the format property, which supports json, binary, protobuf, and delimited, or custom for your own format.

Type
Purpose
NeuronTag data collected by the collection module
MQTTSubscribe to an MQTT topic
HTTP PullPoll an HTTP service on a timer
HTTP PushA built-in HTTP server that receives client pushes
MemoryReceive the output of a previous rule, forming a pipeline
SQLQuery MySQL, PostgreSQL, SQL Server, Oracle, or SQLite
FileRead file contents
VideoPull a video stream
SimulatorBuilt-in simulated data for debugging rules
RedisRead from Redis
CANRead from a CAN bus
KafkaConsume a Kafka topic
WebSocketReceive over WebSocket

Sinks ​

A rule can have several actions, including more than one of the same type. Results can be reshaped by a data template before output; without one, the rule result is written as is.

Type
Purpose
MQTTPublish to an external MQTT service
NeuronWrite back to devices
RESTCall an external HTTP API
MemoryPass to the next rule, forming a pipeline
LogWrite to the log, normally for debugging only
SQLWrite to a relational database
InfluxDB V1 / V2Write to a time-series database
FileWrite to a file
KafkaWrite to a Kafka topic
RedisWrite to Redis
AWS S3Upload to object storage
ImageSave as an image file
NopDiscard output, for performance testing

SQL capabilities ​

CapabilityDescriptionLearn more
Query and transformExtract, convert, filter, sort, group, aggregate, plus LEFT / RIGHT / FULL / CROSS joinsQuery language
Functions160+ covering math, strings, aggregation, hashing, date and time, JSON, arrays, objects, and analyticsFunctions
WindowsTumbling, hopping, sliding, and session time windows, plus count windowsWindows
Custom extensionsWhat SQL cannot express can be written in Python, C/C++, or JavaScript, or registered as an external REST serviceExtensions

How rules run ​

  • A rule runs continuously once started, until stopped manually; it also stops on an error or when the instance exits.
  • Rules are isolated from each other, so an error in one does not affect the others. They share the same hardware, and each rule can set an operator buffer to cap its processing rate.
  • Rules can be chained into a pipeline through memory or MQTT source/sink pairs. See Rule Pipeline.
  • Enable rule testing while creating a rule to see live whether the SQL, functions, and data template produce what you expect.

Configuration ​

The configuration page manages connectors (connection reuse), schemas for decoding formats such as Protobuf, and file management.