Skip to content

Commit 00f9ea6

Browse files
lcawlshainaraskas
andcommitted
[DOCS] Add node specifications to API conventions (elastic#126571)
Co-authored-by: shainaraskas <[email protected]>
1 parent 3f7c5de commit 00f9ea6

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

docs/reference/elasticsearch/rest-apis/api-conventions.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
mapped_pages:
33
- https://www.elastic.co/guide/en/elasticsearch/reference/current/api-conventions.html
4+
- https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html
45
applies_to:
56
stack: all
7+
serverless: all
68
navigation_title: API conventions
79
---
810

@@ -51,7 +53,6 @@ For example, the following `traceparent` value would produce the following `trac
5153
`trace.id`: 0af7651916cd43dd8448eb211c80319c
5254
```
5355

54-
5556
## GET and POST requests [get-requests]
5657

5758
A number of {{es}} GET APIs—​most notably the search API—​support a request body. While the GET action makes sense in the context of retrieving information, GET requests with a body are not supported by all HTTP libraries. All {{es}} GET APIs that require a body can also be submitted as POST requests. Alternatively, you can pass the request body as the [`source` query string parameter](#api-request-body-query-string) when using GET.
@@ -369,7 +370,6 @@ Global index templates that match all indices are not applied to hidden indices.
369370
Direct access to system indices is deprecated and will no longer be allowed in a future major version.
370371
::::
371372

372-
373373
To view system indices within cluster:
374374

375375
```console
@@ -380,7 +380,61 @@ GET _cluster/state/metadata?filter_path=metadata.indices.*.system
380380
When overwriting current cluster state, system indices should be restored as part of their [feature state](docs-content://deploy-manage/tools/snapshot-and-restore.md#feature-state).
381381
::::
382382

383+
### Node specification [cluster-nodes]
384+
385+
Some cluster-level APIs may operate on a subset of the nodes which can be specified with node filters.
386+
For example, [task management]({{es-apis}}group/endpoint-tasks), [node stats]({{es-apis}}operation/operation-nodes-stats), and [node info]({{es-apis}}operation/operation-nodes-info-1) APIs can all report results from a filtered set of nodes rather than from all nodes.
387+
388+
Node filters are written as a comma-separated list of individual filters, each of which adds or removes nodes from the chosen subset.
389+
Each filter can be one of the following:
390+
391+
* `_all`, to add all nodes to the subset.
392+
* `_local`, to add the local node to the subset.
393+
* `_master`, to add the currently-elected master node to the subset.
394+
* a node ID or name, to add this node to the subset.
395+
* an IP address or hostname, to add all matching nodes to the subset.
396+
* a pattern, using `*` wildcards, which adds all nodes to the subset whose name, address, or hostname matches the pattern.
397+
* `master:true`, `data:true`, `ingest:true`, `voting_only:true`, `ml:true`, or `coordinating_only:true`, which respectively add to the subset all master-eligible nodes, all data nodes, all ingest nodes, all voting-only nodes, all machine learning nodes, and all coordinating-only nodes.
398+
* `master:false`, `data:false`, `ingest:false`, `voting_only:false`, `ml:false`, or `coordinating_only:false`, which respectively remove from the subset all master-eligible nodes, all data nodes, all ingest nodes, all voting-only nodes, all machine learning nodes, and all coordinating-only nodes.
399+
* a pair of patterns, using `*` wildcards, of the form `attrname:attrvalue`, which adds to the subset all nodes with a [custom node attribute](/reference/elasticsearch/configuration-reference/node-settings.md#custom-node-attributes) whose name and value match the respective patterns. Custom node attributes are configured by setting properties in the configuration file of the form `node.attr.attrname: attrvalue`.
383400

401+
Node filters run in the order in which they are given, which is important if using filters that remove nodes from the set.
402+
For example, `_all,master:false` means all the nodes except the master-eligible ones.
403+
`master:false,_all` means the same as `_all` because the `_all` filter runs after the `master:false` filter.
404+
405+
If no filters are given, the default is to select all nodes.
406+
If any filters are specified, they run starting with an empty chosen subset.
407+
This means that filters such as `master:false` which remove nodes from the chosen subset are only useful if they come after some other filters.
408+
When used on its own, `master:false` selects no nodes.
409+
410+
Here are some examples of the use of node filters with some [cluster APIs]({{es-apis}}group/endpoint-cluster):
411+
412+
```sh
413+
# If no filters are given, the default is to select all nodes
414+
GET /_nodes
415+
# Explicitly select all nodes
416+
GET /_nodes/_all
417+
# Select just the local node
418+
GET /_nodes/_local
419+
# Select the elected master node
420+
GET /_nodes/_master
421+
# Select nodes by name, which can include wildcards
422+
GET /_nodes/node_name_goes_here
423+
GET /_nodes/node_name_goes_*
424+
# Select nodes by address, which can include wildcards
425+
GET /_nodes/10.0.0.3,10.0.0.4
426+
GET /_nodes/10.0.0.*
427+
# Select nodes by role
428+
GET /_nodes/_all,master:false
429+
GET /_nodes/data:true,ingest:true
430+
GET /_nodes/coordinating_only:true
431+
GET /_nodes/master:true,voting_only:false
432+
# Select nodes by custom attribute
433+
# (for example, with something like `node.attr.rack: 2` in the configuration file)
434+
GET /_nodes/rack:2
435+
GET /_nodes/ra*:2
436+
GET /_nodes/ra*:2*
437+
```
384438

385439
## Parameters [api-conventions-parameters]
386440

0 commit comments

Comments
 (0)