inputs/kapacitor: always tag nested metrics with the source URL#18733
Closed
SAY-5 wants to merge 1 commit intoinfluxdata:masterfrom
Closed
inputs/kapacitor: always tag nested metrics with the source URL#18733SAY-5 wants to merge 1 commit intoinfluxdata:masterfrom
SAY-5 wants to merge 1 commit intoinfluxdata:masterfrom
Conversation
When the kapacitor plugin polls more than one URL, every metric emitted has to carry the source URL so callers can tell the two instances apart. The top-level kapacitor and kapacitor_memstats measurements already attach it, but the nested objects that turn into kapacitor_edges, kapacitor_ingress, kapacitor_load, and friends were only tagged with whatever came out of Kapacitor's /debug/vars payload. Kapacitor itself does not include the URL there (it would not know it), so those rows had no way to be attributed back to their source endpoint. Always set an "url" tag on the AddFields call for the nested objects, unless the object's own tags already contain one (in which case we preserve the more specific value). Fixes influxdata#18645 Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Contributor
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
Member
Author
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.
Fixes #18645.
Problem
When
[[inputs.kapacitor]]polls more than one URL, every emitted metric needs to carry the source URL so downstream consumers can tell the two instances apart. The top-levelkapacitorandkapacitor_memstatsmeasurements already do, but the nested objects that turn intokapacitor_edges,kapacitor_ingress,kapacitor_load, etc. were only tagged with whatever came out of Kapacitor's/debug/varspayload. Kapacitor itself does not include the URL there (it has no way to), so those rows had no way to be attributed back to their source endpoint:(no
urltag, and when two endpoints are polled you cannot tell these apart from each other).Fix
In
plugins/inputs/kapacitor/kapacitor.go, before the nestedacc.AddFieldscall, setobj.Tags["url"] = urlwhen the object doesn't already carry one. The existing code path that copiesobj.Tagsstraight to the field set is preserved (so thetask=...,type=...,child=...,parent=...tags Kapacitor returns are still emitted), and if Kapacitor ever does start including its ownurltag we prefer that more specific value.Back-compat
No change for users who poll a single URL (
urltag becomes visible on a few more measurements). Users who already worked around this with the[inputs.kapacitor.tags] url = "..."block keep working because the hand-configured tag is applied at a later stage by telegraf core, and the new code only setsurlwhen the nested object hadn't already supplied one.Signed off per DCO.