Skip to content

Conversation

@jpig18
Copy link

@jpig18 jpig18 commented Dec 16, 2025

Add leaderOnly parameter to query only stream leader

This adds a new optional 'leaderOnly' parameter to the NATS JetStream scaler that appends '&leader-only=true' to the monitoring URL when enabled. This is useful in clustered NATS deployments to ensure metrics are fetched only from the stream leader node.

Provide a description of what has been changed

Checklist

  • When introducing a new scaler, I agree with the scaling governance policy
  • I have verified that my change is according to the deprecations & breaking changes policy
  • Tests have been added
  • Ensure make generate-scalers-schema has been run to update any outdated generated files.
  • Changelog has been updated and is aligned with our changelog requirements
  • A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #7322

@jpig18 jpig18 requested a review from a team as a code owner December 16, 2025 20:22
@github-actions
Copy link

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

@keda-automation keda-automation requested a review from a team December 16, 2025 20:22
@snyk-io
Copy link

snyk-io bot commented Dec 16, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@jpig18 jpig18 force-pushed the feature/nats-jetstream-leader-only branch 5 times, most recently from a221781 to c2186df Compare December 16, 2025 20:42
@jpig18 jpig18 force-pushed the feature/nats-jetstream-leader-only branch from c2186df to eb83ff8 Compare December 16, 2025 20:47
@JorTurFer
Copy link
Member

JorTurFer commented Dec 16, 2025

Hello
Currently KEDA only checks metrics from leader because only the leader has all the visibility of on-going messages and pending messages. I think that this is a nice improvement because current logic is more complex just to check which is the leader (I didn't know about that parameter tbh and it solves the discovery logic)

I mean, I see the benefit of this change because we can remove logic in place to achieve the same, but it's not something that we need to expose to users because it's the current behaviour. Do you know when the support for that parameter was added?

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.

[FEATURE] Add leaderOnly parameter to NATS JetStream scaler for consistent metrics in clustered deployments

2 participants