2017-07-14 19:45:08 +00:00
|
|
|
---
|
2020-04-07 18:55:19 +00:00
|
|
|
layout: docs
|
2020-04-06 20:27:35 +00:00
|
|
|
page_title: 'Commands: Catalog'
|
2020-04-13 18:40:26 +00:00
|
|
|
sidebar_title: catalog
|
2017-07-14 19:45:08 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Catalog
|
|
|
|
|
|
|
|
Command: `consul catalog`
|
|
|
|
|
|
|
|
The `catalog` command is used to interact with Consul's catalog via the command
|
|
|
|
line. It exposes top-level commands for reading and filtering data from the
|
|
|
|
registry.
|
|
|
|
|
2020-04-09 23:46:54 +00:00
|
|
|
The catalog is also accessible via the [HTTP API](/api/catalog).
|
2017-07-14 19:45:08 +00:00
|
|
|
|
|
|
|
## Basic Examples
|
|
|
|
|
|
|
|
List all datacenters:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog datacenters
|
|
|
|
dc1
|
|
|
|
dc2
|
|
|
|
dc3
|
|
|
|
```
|
|
|
|
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
|
|
|
List all nodes which provide a particular service:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog nodes -service=redis
|
|
|
|
Node ID Address DC
|
|
|
|
worker-01 1b662d97 10.4.5.31 dc1
|
|
|
|
worker-02 d407a592 10.4.4.158 dc1
|
|
|
|
```
|
|
|
|
|
|
|
|
List all services:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog services
|
|
|
|
consul
|
|
|
|
postgresql
|
|
|
|
redis
|
|
|
|
```
|
|
|
|
|
|
|
|
List all services on a node:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-07-14 19:45:08 +00:00
|
|
|
$ consul catalog services -node=worker-01
|
|
|
|
consul
|
|
|
|
postgres
|
|
|
|
```
|
|
|
|
|
|
|
|
For more examples, ask for subcommand help or view the subcommand documentation
|
|
|
|
by clicking on one of the links in the sidebar.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul catalog <subcommand>`
|
|
|
|
|
|
|
|
For the exact documentation for your Consul version, run `consul catalog -h` to
|
|
|
|
view the complete list of subcommands.
|
|
|
|
|
|
|
|
```text
|
|
|
|
Usage: consul catalog <subcommand> [options] [args]
|
|
|
|
|
|
|
|
# ...
|
|
|
|
|
|
|
|
Subcommands:
|
|
|
|
datacenters Lists all known datacenters for this agent
|
|
|
|
nodes Lists all nodes in the given datacenter
|
|
|
|
services Lists all registered services in a datacenter
|
|
|
|
```
|
|
|
|
|
|
|
|
For more information, examples, and usage about a subcommand, click on the name
|
|
|
|
of the subcommand in the sidebar or one of the links below:
|