Skip to content

feat(mqtt source, mqtt sink): add MQTT v5 protocol support#25587

Open
vitalvas wants to merge 9 commits into
vectordotdev:masterfrom
vitalvas:feat/mqtt-v5-protocol
Open

feat(mqtt source, mqtt sink): add MQTT v5 protocol support#25587
vitalvas wants to merge 9 commits into
vectordotdev:masterfrom
vitalvas:feat/mqtt-v5-protocol

Conversation

@vitalvas

@vitalvas vitalvas commented Jun 5, 2026

Copy link
Copy Markdown

Summary

  • Add MQTT v5 protocol support to the mqtt source and mqtt sink, selectable via a new protocol_version option (defaults to v311 for backward compatibility).
  • Expose v5 publish properties (payload format indicator, message expiry, topic alias, response topic, correlation data, content type, user properties) on the sink under a new publish_properties config section, a
    nd surface incoming v5 properties as source event metadata.
  • Add end-to-end acknowledgements to the mqtt source: when enabled, the source switches to MQTT manual ack mode and only sends PubAck to the broker once Vector has delivered the event downstream, providing at-l
    east-once semantics for both v3.1.1 and v5.
  • Derive the sink's accepted input types from the configured encoder so logs, metrics, and traces are all transportable over MQTT (default json encodes all three; use native_json for lossless Vector-to-Vector p
    ipelines). Mis-routed event types are now rejected at config build time instead of silently dropped by the codec.
  • Emit open_connections and connection_shutdown_total telemetry from both source and sink, plus richer component_errors_total coverage for connection, subscribe, and acknowledgement failures.
  • Consolidate the v3 and v5 connection-building code into a shared common::mqtt::build_connector to keep the source and sink in sync.

Vector configuration

sources:
  my_mqtt_source:
    type: mqtt
    host: "mqtt.example.com"
    port: 1883
    topic: "events/#"
    protocol_version: v5
    acknowledgements: true
    connect_properties:
      session_expiry_interval: 300

sinks:
  my_mqtt_sink:
    type: mqtt
    inputs: ["my_mqtt_source"]
    host: "mqtt.example.com"
    port: 1883
    topic: "events/{{ .namespace }}"
    protocol_version: v5                                                                                                                                                                                                  publish_properties:
      content_type: "application/json"
      message_expiry_interval: 3600
      user_properties:
        source: vector
    encoding:
      codec: json

How did you test this PR?

  • New unit tests for connector building (v3/v5, manual_acks propagation, credential and client_id validation), publish-property conversion (all fields, boundary values), QoS conversions, source metadata application
    (v3 and v5, all 7 v5 fields, no-op on non-log events), and direction tagging on connection errors. 25 mqtt unit tests pass.
  • Existing v3.1.1 integration tests continue to pass.
  • Manual verification that the default protocol_version remains v311 and existing configurations behave unchanged.

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.

@vitalvas vitalvas requested review from a team as code owners June 5, 2026 19:42
@github-actions github-actions Bot added domain: sources Anything related to the Vector's sources domain: sinks Anything related to the Vector's sinks domain: external docs Anything related to Vector's external, public documentation docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. labels Jun 5, 2026
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9cd665493e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/mqtt.rs
Comment thread src/common/mqtt.rs
Comment thread website/cue/reference/components/sinks/mqtt.cue Outdated
@vitalvas

vitalvas commented Jun 8, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@vitalvas vitalvas changed the title feat(mqtt): add support mqtt-v5 for source and sink feat(mqtt source, mqtt sink): add MQTT v5 protocol support Jun 8, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fcb871c61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread website/cue/reference/components/sinks/mqtt.cue Outdated
@github-actions github-actions Bot added the domain: ci Anything related to Vector's CI environment label Jun 8, 2026
@vitalvas

vitalvas commented Jun 8, 2026

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rtrieu rtrieu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor suggestions to comply with our style guide

type: string: {}
}
connect_properties: {
description: "MQTT v5 connection properties. Only used when protocol_version is v5."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "MQTT v5 connection properties. Only used when protocol_version is v5."
description: "MQTT v5 connection properties. Only applicable when `protocol_version` is `v5`."

All subscriptions are made at MQTT QoS 1 (AtLeastOnce), and MQTT wildcards
are supported:

- `+` matches exactly one topic level (for example `sensors/+/temperature`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `+` matches exactly one topic level (for example `sensors/+/temperature`)
- `+` matches exactly one topic level (for example ,`sensors/+/temperature`)

are supported:

- `+` matches exactly one topic level (for example `sensors/+/temperature`)
- `#` matches zero or more trailing levels (for example `sensors/#`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `#` matches zero or more trailing levels (for example `sensors/#`)
- `#` matches zero or more trailing levels (for example ,`sensors/#`)

}
}
payload_format_indicator: {
description: "MQTT v5 payload format indicator. 0 indicates unspecified bytes and 1 indicates UTF-8 encoded data. Absent for v3.1.1 messages or v5 messages without the property set."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "MQTT v5 payload format indicator. 0 indicates unspecified bytes and 1 indicates UTF-8 encoded data. Absent for v3.1.1 messages or v5 messages without the property set."
description: "MQTT v5 payload format indicator. 0 indicates unspecified bytes, and 1 indicates UTF-8 encoded data. Absent for v3.1.1 messages or v5 messages without the property set."

protocol_versions: {
title: "MQTT 3.1.1 and 5.0 support"
body: """
The sink supports both MQTT 3.1.1 (default) and MQTT 5.0, selected via the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The sink supports both MQTT 3.1.1 (default) and MQTT 5.0, selected via the
The sink supports both MQTT 3.1.1 (default) and MQTT 5.0, selected using the

title: "MQTT v5 publish properties"
body: """
When `protocol_version` is set to `v5`, the sink can attach MQTT 5.0 publish
properties to outgoing messages via the `publish_properties` section. Supported

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
properties to outgoing messages via the `publish_properties` section. Supported
properties to outgoing messages through the `publish_properties` section. Supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain: ci Anything related to Vector's CI environment domain: external docs Anything related to Vector's external, public documentation domain: sinks Anything related to the Vector's sinks domain: sources Anything related to the Vector's sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants