|
6 | 6 | ["float",id="cluster-nodes"]
|
7 | 7 | == Node specification
|
8 | 8 |
|
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. |
14 | 51 |
|
15 | 52 | [source,js]
|
16 | 53 | --------------------------------------------------
|
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 |
18 | 59 | 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 |
23 | 63 | GET /_nodes/node_name_goes_here
|
24 | 64 | 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) |
26 | 73 | GET /_nodes/rack:2
|
27 | 74 | GET /_nodes/ra*:2
|
28 | 75 | GET /_nodes/ra*:2*
|
|
0 commit comments