Skip to content

inputs/kapacitor: always tag nested metrics with the source URL#18733

Closed
SAY-5 wants to merge 1 commit intoinfluxdata:masterfrom
SAY-5:fix-kapacitor-url-tag-18645
Closed

inputs/kapacitor: always tag nested metrics with the source URL#18733
SAY-5 wants to merge 1 commit intoinfluxdata:masterfrom
SAY-5:fix-kapacitor-url-tag-18645

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 17, 2026

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-level kapacitor and kapacitor_memstats measurements already do, but the nested objects that turn into kapacitor_edges, kapacitor_ingress, kapacitor_load, etc. were only tagged with whatever came out of Kapacitor's /debug/vars payload. 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:

kapacitor_edges,child=stream,parent=write_points,task=task_master:main,type=stream emitted=0,collected=0
kapacitor_load errors=0

(no url tag, and when two endpoints are polled you cannot tell these apart from each other).

Fix

In plugins/inputs/kapacitor/kapacitor.go, before the nested acc.AddFields call, set obj.Tags["url"] = url when the object doesn't already carry one. The existing code path that copies obj.Tags straight to the field set is preserved (so the task=..., type=..., child=..., parent=... tags Kapacitor returns are still emitted), and if Kapacitor ever does start including its own url tag we prefer that more specific value.

Back-compat

No change for users who poll a single URL (url tag 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 sets url when the nested object hadn't already supplied one.

Signed off per DCO.

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>
@telegraf-tiger
Copy link
Copy Markdown
Contributor

@srebhan
Copy link
Copy Markdown
Member

srebhan commented Apr 17, 2026

@SAY-5 please stop copying existing PRs (#18646 in this case)!

@srebhan srebhan closed this Apr 17, 2026
@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented Apr 17, 2026

Apologies @srebhan — I didn't see #18646 was already open against the same issue. Duplicate is entirely on me, will check the open-PR list more carefully before filing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kapacitor metrics cannot be identified due to missing url tag

2 participants