2017-07-14 19:45:08 +00:00
|
|
|
---
|
2020-09-01 15:14:13 +00:00
|
|
|
layout: commands
|
2020-04-07 18:55:19 +00:00
|
|
|
page_title: 'Commands: Catalog List Nodes'
|
2017-07-14 19:45:08 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Catalog List Nodes
|
|
|
|
|
|
|
|
Command: `consul catalog nodes`
|
|
|
|
|
2022-01-11 13:26:58 +00:00
|
|
|
Corresponding HTTP API Endpoint: [\[GET\] /v1/catalog/nodes](/api-docs/catalog#list-nodes)
|
2022-01-10 17:40:11 +00:00
|
|
|
|
2017-07-14 19:45:08 +00:00
|
|
|
The `catalog nodes` command prints all known nodes and metadata about them.
|
|
|
|
It can also query for nodes that match a particular metadata or provide a
|
|
|
|
particular service.
|
|
|
|
|
2022-01-10 21:44:56 +00:00
|
|
|
The table below shows this command's [required ACLs](/api#authentication). Configuration of
|
|
|
|
[blocking queries](/api/features/blocking) and [agent caching](/api/features/caching)
|
|
|
|
are not supported from commands, but may be from the corresponding HTTP endpoint.
|
|
|
|
|
|
|
|
| ACL Required |
|
|
|
|
| ------------ |
|
|
|
|
| `node:read` |
|
|
|
|
|
2017-07-14 19:45:08 +00:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
List all nodes:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog nodes
|
|
|
|
Node ID Address DC
|
|
|
|
worker-01 1b662d97 10.4.5.31 dc1
|
|
|
|
```
|
|
|
|
|
|
|
|
Print detailed node information such as tagged addresses and node metadata:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog nodes -detailed
|
|
|
|
Node ID Address DC TaggedAddresses Meta
|
|
|
|
worker-01 1b662d97-8b5c-3cc2-0ac0-96f55ad423b5 10.4.5.31 dc1 lan=10.4.5.31, wan=10.4.5.31
|
|
|
|
```
|
|
|
|
|
|
|
|
List nodes which provide the service name "web":
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog nodes -service=web
|
|
|
|
Node ID Address DC TaggedAddresses Meta
|
|
|
|
worker-01 1b662d97-8b5c-3cc2-0ac0-96f55ad423b5 10.4.5.31 dc1 lan=10.4.5.31, wan=10.4.5.31
|
|
|
|
```
|
|
|
|
|
|
|
|
Sort the resulting node list by estimated round trip time to worker-05:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog nodes -near=web-05
|
|
|
|
Node ID Address DC TaggedAddresses Meta
|
|
|
|
worker-01 1b662d97-8b5c-3cc2-0ac0-96f55ad423b5 10.4.5.31 dc1 lan=10.4.5.31, wan=10.4.5.31
|
|
|
|
worker-02 d407a592-e93c-4d8e-8a6d-aba853d1e067 10.4.4.158 dc1 lan=10.4.4.158, wan=10.4.4.158
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul catalog nodes [options]`
|
|
|
|
|
|
|
|
#### API Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_options_client.mdx'
|
2020-04-07 23:56:08 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_options_server.mdx'
|
2017-07-14 19:45:08 +00:00
|
|
|
|
|
|
|
#### Catalog List Nodes Options
|
|
|
|
|
|
|
|
- `-detailed` - Output detailed information about the nodes including their
|
|
|
|
addresses and metadata.
|
|
|
|
|
|
|
|
- `-near=<string>`- Node name to sort the node list in ascending order based on
|
|
|
|
estimated round-trip time from that node. Passing `"_agent"` will use this
|
|
|
|
agent's node for sorting.
|
|
|
|
|
|
|
|
- `-node-meta=<key=value>` - Metadata to filter nodes with the given key=value
|
|
|
|
pairs. This flag may be specified multiple times to filter on multiple sources
|
|
|
|
of metadata.
|
|
|
|
|
|
|
|
- `-service=<id or name>` - Service id or name to filter nodes. Only nodes
|
|
|
|
which are providing the given service will be returned.
|
2019-04-16 16:00:15 +00:00
|
|
|
|
|
|
|
- `-filter=<filter>` - Expression to use for filtering the results. Can be passed
|
2020-04-07 18:55:19 +00:00
|
|
|
via stdin by using `-` for the value or from a file by passing `@<file path>`.
|
2020-04-09 23:46:54 +00:00
|
|
|
See the [`/catalog/nodes` API documentation](/api/catalog#filtering) for a
|
2020-04-07 18:55:19 +00:00
|
|
|
description of what is filterable.
|
2021-12-15 01:55:21 +00:00
|
|
|
|
|
|
|
#### Enterprise Options
|
|
|
|
|
|
|
|
@include 'http_api_partition_options.mdx'
|