Skip to main content

sparkplug_b output

Sparkplug B MQTT output acting as Edge Node

# Config fields, showing default values
output:
label: ""
sparkplug_b:
mqtt:
urls: ["tcp://localhost:1883"]
client_id: "benthos-sparkplug-output"
credentials:
username: ""
password: ""
qos: 1
keep_alive: "60s"
connect_timeout: "30s"
clean_session: true
identity:
group_id: "" # No default (required)
edge_node_id: "" # No default (required)
device_id: ""
metrics: [] # No default (optional)
behavior:
auto_extract_tag_name: true
retain_last_values: true

The Sparkplug B output acts as an Edge Node, publishing data to Sparkplug MQTT topics with complete session lifecycle management. It handles BIRTH/DEATH certificates, maintains sequence numbers, manages alias mappings, and ensures full Sparkplug B compliance.

Key features:

  • Always operates as Edge Node (no role configuration needed)
  • Automatic NBIRTH/DBIRTH on connect with metric definitions
  • NDEATH/DDEATH Last Will Testament on disconnect
  • Sequence number management with proper wrapping
  • Alias-based metric publishing for bandwidth efficiency
  • Automatic type detection and conversion
  • Configurable metric definitions with aliases
  • Robust reconnection handling with proper rebirth
  • UNS metadata integration for seamless data flow

The output connects to an MQTT broker, publishes BIRTH certificates to announce available metrics, and then publishes DATA messages as Expanso Edge messages flow through the pipeline.

Fields​

mqtt​

MQTT transport configuration

Type: object

mqtt.urls​

List of MQTT broker URLs to connect to

Type: array of string
Default: ["tcp://localhost:1883"]

mqtt.client_id​

MQTT client ID for this edge node

Type: string
Default: "benthos-sparkplug-output"

mqtt.credentials​

MQTT authentication credentials

Type: object

mqtt.credentials.username​

MQTT username for authentication

Type: string
Default: ""

mqtt.credentials.password​

MQTT password for authentication

Secret

This field contains sensitive information. Use a secret reference rather than a literal value.

Type: string
Default: ""

mqtt.qos​

QoS level for MQTT publishing (0, 1, or 2)

Type: int
Default: 1

mqtt.keep_alive​

MQTT keep alive interval

Type: string
Default: "60s"

mqtt.connect_timeout​

MQTT connection timeout

Type: string
Default: "30s"

mqtt.clean_session​

MQTT clean session flag

Type: bool
Default: true

identity​

Sparkplug identity configuration

Type: object

identity.group_id​

Sparkplug Group ID (e.g., 'FactoryA')

Type: string

identity.edge_node_id​

Edge Node ID within the group (e.g., 'Line3'). If empty, auto-generated from location_path metadata using Parris Method

Type: string

identity.device_id​

Device ID under the edge node (optional, if not specified acts as node-level)

Type: string
Default: ""

metrics​

Metric definitions for BIRTH messages and alias mapping

Type: array of object

metrics[].name​

Metric name as it will appear in BIRTH messages

Type: string

metrics[].alias​

Numeric alias for this metric (1-65535)

Type: int

metrics[].type​

Data type: int8, int16, int32, int64, uint8, uint16, uint32, uint64, float, double, boolean, string

Type: string
Default: "double"

metrics[].value_from​

Top-level field name in the message to extract value from

Type: string
Default: "value"

behavior​

Processing behavior configuration

Type: object

behavior.auto_extract_tag_name​

Whether to automatically extract tag_name from message metadata

Type: bool
Default: true

behavior.retain_last_values​

Whether to retain last known values for BIRTH messages after reconnection

Type: bool
Default: true