|
6 | 6 | ["float",id="cluster-nodes"] |
7 | 7 | == Node specification |
8 | 8 |
|
9 | | -Some cluster level APIs allow to specify nodes with _node filters_, these filters |
10 | | -limit the results to selected nodes for corresponding APIs. (For example, you can |
11 | | -find it in <<tasks,Task Management>> API and all the Nodes APIs like |
12 | | -<<cluster-nodes-stats,Nodes Stats>>, <<cluster-nodes-info,Nodes Info>> etc.) |
13 | | - |
14 | | -_Node filters_ can be one or a list filters which is comma-seperated, each filter can be: |
15 | | - |
16 | | -* `_local` |
17 | | -* `_master` |
18 | | -* `_all` |
19 | | -* a node id |
20 | | -* a node name, node address or node hostname (could be a pattern matched using `*` wildcard) |
21 | | -* `[master|data|ingest|coordinating_only]:[true|false]` <1> <2> |
22 | | -* custom `attr:value` (need to be set in configuration file and could be a pattern matched using `*` wildcard) <3> |
23 | | - |
24 | | -[NOTE] |
25 | | -=============================================== |
26 | | -<1> pay attention that `master` means master-eligible nodes, not the current master which is represented by `_master`. |
27 | | -<2> `false` means exclude the specified type of nodes. |
28 | | -<3> the custom `attr:value` should be defined in configuration file. |
29 | | -=============================================== |
30 | | - |
31 | | -IMPORTANT: node filters run in order in case of multiple, this is important when you use the exclusion case, |
32 | | -for example `/_all,master:false` means all the nodes exclude master-eligible, but `/master:false,_all` means |
33 | | -all the nodes as you exclude the master-eligible nodes firstly and then add all nodes in. |
34 | | - |
35 | | -Here are some node filters examples: |
| 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, to add this node to the set. |
| 22 | +* a pattern, using `*` wildcards, which adds all nodes to the subset |
| 23 | + whose name, address or hostname matches the pattern. |
| 24 | +* `master:true`, `data:true`, `ingest:true` or `coordinating_only:true`, which |
| 25 | + respectively add to the subset all master-eligible nodes, all data nodes, |
| 26 | + all ingest nodes, and all coordinating-only nodes. |
| 27 | +* `master:false`, `data:false`, `ingest:false` or `coordinating_only:false`, |
| 28 | + which respectively remove from the subset all master-eligible nodes, all data |
| 29 | + nodes, all ingest nodes, and all coordinating-only nodes. |
| 30 | +* a pattern, using `*` wildcards, of the form `attrname:attrvalue`, which adds |
| 31 | + to the subset all nodes with a custom node attribute that matches the |
| 32 | + pattern. Custom node attributes are configured by setting properties in the |
| 33 | + configuration file of the form `node.attr.attrname: attrvalue`. |
| 34 | + |
| 35 | +NOTE: node filters run in the order in which they are given, which is important |
| 36 | +if using filters that remove nodes from the set. For example |
| 37 | +`_all,master:false` means all the nodes except the master-eligible ones, but |
| 38 | +`master:false,_all` means the same as `_all` because the `_all` filter runs |
| 39 | +after the `master:false` filter. |
| 40 | + |
| 41 | +NOTE: if no filters are given, the default is to select all nodes. However, if |
| 42 | +any filters are given then they run starting with an empty chosen subset. This |
| 43 | +means that filters such as `master:false` which remove nodes from the chosen |
| 44 | +subset are only useful if they come after some other filters. When used on its |
| 45 | +own, `master:false` selects no nodes. |
| 46 | + |
| 47 | +Here are some examples of the use of node filters with the |
| 48 | +<<cluster-nodes-info,Nodes Info>> APIs. |
36 | 49 |
|
37 | 50 | [source,js] |
38 | 51 | -------------------------------------------------- |
39 | | -# Local node |
| 52 | +# If no filters are given, the default is to select all nodes |
| 53 | +GET /_nodes |
| 54 | +# Explicitly select all nodes |
| 55 | +GET /_nodes/_all |
| 56 | +# Select just the local node |
40 | 57 | GET /_nodes/_local |
41 | | -# Master node |
| 58 | +# Select the elected master node |
42 | 59 | GET /_nodes/_master |
43 | | -# All nodes |
44 | | -GET /_nodes/_all |
45 | | -# Using node name |
| 60 | +# Select nodes by name, which can include wildcards |
46 | 61 | GET /_nodes/node_name_goes_here |
47 | 62 | GET /_nodes/node_name_goes_* |
48 | | -# Using address |
| 63 | +# Select nodes by address, which can include wildcards |
49 | 64 | GET /_nodes/10.0.0.3,10.0.0.4 |
50 | 65 | GET /_nodes/10.0.0.* |
51 | | -# Using built-in `attr:value` |
| 66 | +# Select nodes by role |
52 | 67 | GET /_nodes/_all,master:false |
53 | 68 | GET /_nodes/data:true,ingest:true |
54 | 69 | GET /_nodes/coordinating_only:true |
55 | | -# Using custom `attr:value` (set something like `node.attr.rack: 2` in configuration file) |
| 70 | +# Select nodes by custom attribute (e.g. with something like `node.attr.rack: 2` in the configuration file) |
56 | 71 | GET /_nodes/rack:2 |
57 | 72 | GET /_nodes/ra*:2 |
58 | 73 | GET /_nodes/ra*:2* |
|
0 commit comments