-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[elasticsearch] Add the local query parameter when fetching cluster state #36586
Conversation
@DaveCTurner FYI, following up on the comment you made in a recent Discuss thread, I'm hoping I understood correctly the changes suggested. |
Admittedly I don't read Golang so good, but I could well believe that this does indeed add the |
@@ -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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the insight!
…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]>
…tate (elastic#36586) * [elasticsearch] Add the local query parameter when fetching cluster state * Fix lint issues
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.