[Mosquitto] Add new integration for Eclipse Mosquitto broker logs - #20937
Open
smnschndr wants to merge 1 commit into
Open
[Mosquitto] Add new integration for Eclipse Mosquitto broker logs#20937smnschndr wants to merge 1 commit into
smnschndr wants to merge 1 commit into
Conversation
Contributor
ReviewersBuildkite won't run for external contributors automatically; you need to add a comment:
NOTE: https://github.com/elastic/integrations/blob/main/.buildkite/pull-requests.json contains all those details. |
smnschndr
added a commit
to smnschndr/integrations
that referenced
this pull request
Aug 27, 2026
Replaces the pull/99999 development placeholder with elastic#20937. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MiE73xyXFRoUCPgwdbgwtc
Adds a `mosquitto` integration collecting Eclipse Mosquitto MQTT broker logs through the filestream input. One data stream, `log`. No dashboards yet. The timestamp handling is the substantive part. Mosquitto prefixes each line in one of two mutually exclusive formats depending on a single broker setting: with `log_timestamp_format` unset (the default) it writes Unix epoch seconds, always UTC; with `log_timestamp_format %Y-%m-%dT%H:%M:%S` (the form the Mosquitto documentation uses as its example, so it is common) it writes a strftime timestamp. Both are handled on a single pipeline path rather than in two branches: one grok splits the prefix from the body, and a small set of date processors resolves whichever variant matched. `log_timestamp false` is handled too, tagged `mosquitto_missing_timestamp` rather than dropped. Two details were verified against the Mosquitto source rather than assumed: - The formatted variant is rendered with `localtime()` and carries no UTC offset (src/logging.c, get_time), while the epoch default is always UTC. A `tz_offset` policy option is therefore wired to the date processor for the formatted case only. - When an operator adds `%z`, glibc renders the offset without a colon (`+0200`). Elasticsearch's ISO8601 format accepts that; both `+0200` and `+02:00` have permanent fixture coverage. Message bodies are parsed into ECS plus a `mosquitto.log.*` namespace, covering MQTT control packets (topic, QoS, message id, payload size, dup and retain flags), connection lifecycle, subscription grants and denials, broker lifecycle and errors. The grok patterns derive from the `log__printf` format strings in the Mosquitto source rather than from sample data alone, so they also cover the 1.6-era disconnect wording that omits the client address. Unrecognised lines are still indexed with their full text in `message`. Mosquitto's file and stdout destinations write no severity marker at all, so `log.level` is inferred from each message's wording. The README says so, to keep the heuristic from being mistaken for a vendor-supplied field. Verification: `elastic-package check` clean; 6 pipeline tests; 2 system test configs exercising the ISO and epoch variants end to end. Over the 39 lines the two fixtures share, the resulting documents are identical except for `event.original`. Against a real 2591-line broker log (not committed, as it is not synthetic) the pipeline produced zero errors, with only 9 lines (0.3%) yielding no structured fields, all of them `No will message specified.` The package icon is a placeholder: the Eclipse Mosquitto logo is an Eclipse Foundation trademark whose usage policy does not grant third-party redistribution, so a neutral mark is shipped pending clearance. `owner` is set to elastic/integrations-triaging so the triage team routes the package, per the default entry in .github/CODEOWNERS, which is left unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MiE73xyXFRoUCPgwdbgwtc
smnschndr
force-pushed
the
worktree-mosquitto-integration
branch
from
August 27, 2026 09:13
eafba52 to
fcfcf80
Compare
smnschndr
marked this pull request as ready for review
August 27, 2026 09:22
Contributor
Author
|
/test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Adds a new
mosquittointegration that collects the log of an Eclipse Mosquitto MQTT broker through thefilestreaminput. One data stream,log. No dashboards in this initial release.WHY: Mosquitto is a widely deployed open source MQTT broker, and its log is the only place where client connections, subscription grants, published topics and broker errors are visible. There is currently no Elastic integration for it.
WHAT — the timestamp handling is the substantive part of this PR.
Mosquitto prefixes each log line with a timestamp in one of two mutually exclusive formats, and which one you get depends on a single broker setting:
log_timestamp_formatunset (the default) writes Unix epoch seconds, always UTC.log_timestamp_format %Y-%m-%dT%H:%M:%Swrites astrftimetimestamp. This is what the Mosquitto documentation shows as its example, so it is common in the wild.Both are handled by a single pipeline path rather than two branches: one grok splits the prefix from the body, and a small set of
dateprocessors resolves whichever variant matched.log_timestamp falseis also handled — those documents are taggedmosquitto_missing_timestampand keep the collection time rather than being dropped or erroring.Two details worth flagging for review, both verified against the Mosquitto source rather than assumed:
localtime()and carries no UTC offset (src/logging.cget_time), while the epoch default is always UTC. Atz_offsetpolicy option is therefore wired through to the date processor for the formatted case only.%z, glibc renders the offset without a colon (+0200). Elasticsearch'sISO8601format accepts that form; there is a permanent test fixture line for both+0200and+02:00.Message bodies are parsed into ECS plus a
mosquitto.log.*namespace, covering MQTT control packets (topic, QoS, message ID, payload size, dup/retain flags), connection lifecycle, subscription grants and denials, broker lifecycle and errors. The grok patterns were derived from thelog__printfformat strings in the Mosquitto source, not only from sample data, so they also cover the 1.6-era disconnect wording that omits the client address. Unrecognised lines are still indexed with their full text inmessage.Mosquitto's file and stdout destinations write no severity marker at all, so
log.levelis derived from the wording of each message. This is documented in the README so the heuristic is not mistaken for a vendor-supplied field.Checklist
changelog.ymlfile.Author's Checklist
Open items the reviewer should weigh in on:
img/mosquitto-logo.svgis a neutral hand-drawn mark. The Eclipse Mosquitto logo was deliberately not used, to avoid shipping a trademarked asset without clearance. Guidance on sourcing the correct asset would be welcome.owneris set toelastic/integrations-triagingso the triage team can route this, rather than pre-empting the assignment.owner.typeiscommunity.valewas not run. It is not installed in the author's environment, so the docs were checked manually against the Elastic style rules instead. Worth a fresh pass in CI.log_type unsubscribeline is a bare client id and topic separated by a space. That shape cannot be distinguished from ordinary two-word log messages, so it is indexed without a parsed topic. The accompanyingUNSUBSCRIBEpacket line is parsed normally.How to test this PR locally
The system test runs twice against the same broker log rendered in both timestamp formats, which is the clearest demonstration that the two paths converge.
Beyond the committed fixtures, the pipeline was run against a real 2591-line broker log captured from a Mosquitto 2.0.22 instance: zero pipeline errors, and only 9 lines (0.3%) produced no structured fields — all of them
No will message specified., which carries nothing to extract. That log is not committed, as it is not synthetic.To confirm the two timestamp variants really do converge, the generated expected outputs can be compared directly. Over the 39 log lines the two fixtures share, the resulting documents are identical except for
event.original— same@timestamp, same parsed fields. The ISO fixture carries two extra lines beyond those 39, covering the%zoffset forms that have no epoch equivalent, so the comparison is bounded to the common prefix:Related issues