Skip to content

Commit 05924e8

Browse files
PnPieDaveCTurner
authored andcommitted
Update docs for node specifications (#30468)
Expands and clarifies exactly what is and isn't allowed when specifying a subset of the nodes as targets of a cluster API, and adds missing links to this from the hot threads and cluster stats API docs. Co-authored-by: David Turner <[email protected]> Co-authored-by: Yu <[email protected]>
1 parent 233e748 commit 05924e8

File tree

3 files changed

+83
-16
lines changed

3 files changed

+83
-16
lines changed

docs/reference/cluster.asciidoc

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,70 @@
66
["float",id="cluster-nodes"]
77
== Node specification
88

9-
Most cluster level APIs allow to specify which nodes to execute on (for
10-
example, getting the node stats for a node). Nodes can be identified in
11-
the APIs either using their internal node id, the node name, address,
12-
custom attributes, or just the `_local` node receiving the request. For
13-
example, here are some sample executions of nodes info:
9+
Some cluster-level APIs may operate on a subset of the nodes which can be
10+
specified with _node filters_. For example, the <<tasks,Task Management>>,
11+
<<cluster-nodes-stats,Nodes Stats>>, and <<cluster-nodes-info,Nodes Info>> APIs
12+
can all report results from a filtered set of nodes rather than from all nodes.
13+
14+
_Node filters_ are written as a comma-separated list of individual filters,
15+
each of which adds or removes nodes from the chosen subset. Each filter can be
16+
one of the following:
17+
18+
* `_all`, to add all nodes to the subset.
19+
* `_local`, to add the local node to the subset.
20+
* `_master`, to add the currently-elected master node to the subset.
21+
* a node id or name, to add this node to the subset.
22+
* an IP address or hostname, to add all matching nodes to the subset.
23+
* a pattern, using `*` wildcards, which adds all nodes to the subset
24+
whose name, address or hostname matches the pattern.
25+
* `master:true`, `data:true`, `ingest:true` or `coordinating_only:true`, which
26+
respectively add to the subset all master-eligible nodes, all data nodes,
27+
all ingest nodes, and all coordinating-only nodes.
28+
* `master:false`, `data:false`, `ingest:false` or `coordinating_only:false`,
29+
which respectively remove from the subset all master-eligible nodes, all data
30+
nodes, all ingest nodes, and all coordinating-only nodes.
31+
* a pair of patterns, using `*` wildcards, of the form `attrname:attrvalue`,
32+
which adds to the subset all nodes with a custom node attribute whose name
33+
and value match the respective patterns. Custom node attributes are
34+
configured by setting properties in the configuration file of the form
35+
`node.attr.attrname: attrvalue`.
36+
37+
NOTE: node filters run in the order in which they are given, which is important
38+
if using filters that remove nodes from the set. For example
39+
`_all,master:false` means all the nodes except the master-eligible ones, but
40+
`master:false,_all` means the same as `_all` because the `_all` filter runs
41+
after the `master:false` filter.
42+
43+
NOTE: if no filters are given, the default is to select all nodes. However, if
44+
any filters are given then they run starting with an empty chosen subset. This
45+
means that filters such as `master:false` which remove nodes from the chosen
46+
subset are only useful if they come after some other filters. When used on its
47+
own, `master:false` selects no nodes.
48+
49+
Here are some examples of the use of node filters with the
50+
<<cluster-nodes-info,Nodes Info>> APIs.
1451

1552
[source,js]
1653
--------------------------------------------------
17-
# Local
54+
# If no filters are given, the default is to select all nodes
55+
GET /_nodes
56+
# Explicitly select all nodes
57+
GET /_nodes/_all
58+
# Select just the local node
1859
GET /_nodes/_local
19-
# Address
20-
GET /_nodes/10.0.0.3,10.0.0.4
21-
GET /_nodes/10.0.0.*
22-
# Names
60+
# Select the elected master node
61+
GET /_nodes/_master
62+
# Select nodes by name, which can include wildcards
2363
GET /_nodes/node_name_goes_here
2464
GET /_nodes/node_name_goes_*
25-
# Attributes (set something like node.attr.rack: 2 in the config)
65+
# Select nodes by address, which can include wildcards
66+
GET /_nodes/10.0.0.3,10.0.0.4
67+
GET /_nodes/10.0.0.*
68+
# Select nodes by role
69+
GET /_nodes/_all,master:false
70+
GET /_nodes/data:true,ingest:true
71+
GET /_nodes/coordinating_only:true
72+
# Select nodes by custom attribute (e.g. with something like `node.attr.rack: 2` in the configuration file)
2673
GET /_nodes/rack:2
2774
GET /_nodes/ra*:2
2875
GET /_nodes/ra*:2*

docs/reference/cluster/nodes-hot-threads.asciidoc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
[[cluster-nodes-hot-threads]]
22
== Nodes hot_threads
33

4-
An API allowing to get the current hot threads on each node in the
5-
cluster. Endpoints are `/_nodes/hot_threads`, and
6-
`/_nodes/{nodesIds}/hot_threads`.
4+
This API yields a breakdown of the hot threads on each selected node in the
5+
cluster. Its endpoints are `/_nodes/hot_threads` and
6+
`/_nodes/{nodes}/hot_threads`:
77

8-
The output is plain text with a breakdown of each node's top hot
9-
threads. Parameters allowed are:
8+
[source,js]
9+
--------------------------------------------------
10+
GET /_nodes/hot_threads
11+
GET /_nodes/nodeId1,nodeId2/hot_threads
12+
--------------------------------------------------
13+
// CONSOLE
14+
15+
The first command gets the hot threads of all the nodes in the cluster. The
16+
second command gets the hot threads of only `nodeId1` and `nodeId2`. Nodes can
17+
be selected using <<cluster-nodes,node filters>>.
18+
19+
The output is plain text with a breakdown of each node's top hot threads. The
20+
allowed parameters are:
1021

1122
[horizontal]
1223
`threads`:: number of hot threads to provide, defaults to 3.

docs/reference/cluster/stats.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,12 @@ Will return, for example:
213213
// 3. All of the numbers and strings on the right hand side of *every* field in
214214
// the response are ignored. So we're really only asserting things about the
215215
// the shape of this response, not the values in it.
216+
217+
This API can be restricted to a subset of the nodes using the `?nodeId`
218+
parameter, which accepts <<cluster-nodes,node filters>>:
219+
220+
[source,js]
221+
--------------------------------------------------
222+
GET /_cluster/stats?nodeId=node1,node*,master:false
223+
--------------------------------------------------
224+
// CONSOLE

0 commit comments

Comments
 (0)