Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[elasticsearch] Add the local query parameter when fetching cluster state #36586

Merged
merged 5 commits into from
Sep 22, 2023

Conversation

miltonhultgren
Copy link
Contributor

When using scope: cluster we expect the cluster to be exposed through a single endpoint (either a single non-master eligible node or a load balancer across all non-master eligible nodes).
Because we use parts of the cluster state for many things across various metricsets it is important that we request the parts we need from the non-master eligible nodes to not cause undue load on the master eligible nodes, by adding local=true we ensure that the state is only fetched from the node we're talking to and not via the master node.

@miltonhultgren miltonhultgren added module Team:Infra Monitoring UI - DEPRECATED Infrastructure Monitoring UI team - DEPRECATED - Use Team:Monitoring Module:elasticsearch Elasticsearch Beats modules backport-v8.10.0 Automated backport with mergify labels Sep 13, 2023
@miltonhultgren miltonhultgren requested a review from a team as a code owner September 13, 2023 19:49
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Sep 13, 2023
@miltonhultgren
Copy link
Contributor Author

@DaveCTurner FYI, following up on the comment you made in a recent Discuss thread, I'm hoping I understood correctly the changes suggested.

@DaveCTurner
Copy link

Admittedly I don't read Golang so good, but I could well believe that this does indeed add the ?local=true query parameter to the GET _cluster/state calls as I suggested :)

@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 13, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-09-22T08:25:53.273+0000

  • Duration: 53 min 39 sec

Test stats 🧪

Test Results
Failed 0
Passed 4413
Skipped 913
Total 5326

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@@ -31,7 +31,7 @@ func init() {
}

const (
statePath = "/_cluster/state/version,nodes,master_node,routing_table"
statePath = "/_cluster/state/version,nodes,master_node,routing_table?local=true"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we miss data in a scope: cluster scenario where we only have one metricbeat process ? i'd expect local=true to be set only when scope: node

Copy link
Contributor Author

@miltonhultgren miltonhultgren Sep 22, 2023

Choose a reason for hiding this comment

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

While developing this, I compared the results of the API with and without this flag and they were the same.
Maybe the result could differ between types of nodes, like a master nodes reply versus a data nodes reply, that I didn't compare. I just looked at if a data nodes reply changed between the versions (with and without flag).

@DaveCTurner Can you confirm if that's always the case?

Choose a reason for hiding this comment

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

No (or at least this change doesn't make a meaningful difference in that regard). The ?local=true parameter means "give me your local copy of the entire cluster state rather than forwarding this request to the elected master" but you get the same state either way (in fact sometimes you'll get a slightly fresher state with ?local=true, and sometimes ?local=true will succeed when ?local=false would fail, so this seems like the right change)

Choose a reason for hiding this comment

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

"No" as in:

Would we miss data in a scope: cluster scenario where we only have one metricbeat process ?

No

Can you confirm if that's always the case?

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the insight!

@miltonhultgren miltonhultgren merged commit 2830492 into elastic:main Sep 22, 2023
mergify bot pushed a commit that referenced this pull request Sep 22, 2023
…tate (#36586)

* [elasticsearch] Add the local query parameter when fetching cluster state

* Fix lint issues

(cherry picked from commit 2830492)
miltonhultgren added a commit that referenced this pull request Sep 22, 2023
…tate (#36586) (#36656)

* [elasticsearch] Add the local query parameter when fetching cluster state

* Fix lint issues

(cherry picked from commit 2830492)

Co-authored-by: Milton Hultgren <[email protected]>
Scholar-Li pushed a commit to Scholar-Li/beats that referenced this pull request Feb 5, 2024
…tate (elastic#36586)

* [elasticsearch] Add the local query parameter when fetching cluster state

* Fix lint issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.10.0 Automated backport with mergify Module:elasticsearch Elasticsearch Beats modules module Team:Infra Monitoring UI - DEPRECATED Infrastructure Monitoring UI team - DEPRECATED - Use Team:Monitoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants