Skip to content

in_prometheus_scrape: call flb_input_upstream_set to apply net.* config#12095

Open
labros-mediaalpha wants to merge 1 commit into
fluent:masterfrom
labros-mediaalpha:fix/in_prometheus_scrape-upstream-set
Open

in_prometheus_scrape: call flb_input_upstream_set to apply net.* config#12095
labros-mediaalpha wants to merge 1 commit into
fluent:masterfrom
labros-mediaalpha:fix/in_prometheus_scrape-upstream-set

Conversation

@labros-mediaalpha

@labros-mediaalpha labros-mediaalpha commented Jul 13, 2026

Copy link
Copy Markdown

This PR description was AI-assisted (Claude Code).

What does this PR do?

Adds the missing flb_input_upstream_set() call in
in_prometheus_scrape, following the same pattern already merged for
in_kubernetes_events (#11188) and in_calyptia_fleet (#10998).

Note: this fix alone is not sufficient to restore connection reuse —
see #12094 and the companion PR against flb_input_upstream_set()
itself. Verified via packet capture that this change on its own produces
no observable difference; both PRs are needed together.

Screenshots

N/A (backend networking change, verified via tcpdump/debug log — see
linked issue)

Testing

Manually verified against a live instance running v5.0.7 + this patch:
loopback packet capture (tcpdump -i lo) and -vv debug logging, in
combination with the companion core fix.

Ref #12094

Summary by CodeRabbit

  • Bug Fixes
    • Improved Prometheus scraping startup reliability by validating upstream configuration before activation.
    • Added cleanup handling when upstream setup fails, preventing incomplete configurations from continuing.

prom_scrape_context_create() calls flb_upstream_create() but never
calls flb_input_upstream_set(), so net.* properties (including
net.keepalive) are parsed but never applied to the plugin's upstream.

Same fix already applied to in_kubernetes_events (fluent#11188) and
in_calyptia_fleet (fluent#10998).

Ref fluent#12094

Signed-off-by: Labros Chaidas <labros@mediaalpha.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf96511e-a266-4a38-9a4b-037f58a704ef

📥 Commits

Reviewing files that changed from the base of the PR and between 5c5b8ce and ce8b8d7.

📒 Files selected for processing (1)
  • plugins/in_prometheus_scrape/prom_scrape.c

📝 Walkthrough

Walkthrough

The Prometheus scrape plugin now binds its upstream to the input and cleans up the upstream and context if binding fails.

Changes

Prometheus scrape upstream binding

Layer / File(s) Summary
Upstream binding and cleanup
plugins/in_prometheus_scrape/prom_scrape.c
prom_scrape_create calls flb_input_upstream_set and handles errors by logging, destroying the upstream, freeing the context, and returning NULL.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

Suggested reviewers: eschabell, edsiper, davidkorczynski

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding flb_input_upstream_set() in in_prometheus_scrape to apply net.* configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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: ce8b8d7053

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return NULL;
}

if (flb_input_upstream_set(upstream, ins) != 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Set the keepalive stream flag when applying net settings

When prometheus_scrape uses the default or explicit net.keepalive On, this call copies ins->net_setup.keepalive but leaves the upstream flags as the FLB_IO_TCP value created above. create_conn() initializes conn->recycle from flb_stream_is_keepalive(&u->base), so the connection is still destroyed on release and the new net.keepalive support remains ineffective; the input path needs the same keepalive flag update that output upstream setup performs before the upstream is used.

Useful? React with 👍 / 👎.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant