open-consul/website/content/commands/snapshot/inspect.mdx

159 lines
5.7 KiB
Plaintext
Raw Normal View History

2020-04-07 18:55:19 +00:00
---
layout: commands
2020-04-07 18:55:19 +00:00
page_title: 'Commands: Snapshot Inspect'
description: |
The `consul snapshot inspect` command outputs an atomic, point-in-time snapshot of the state of the Consul servers. Output includes key/value entries, registered services in the catalog, prepared queries, sessions, and ACLs.
2020-04-07 18:55:19 +00:00
---
# Consul Snapshot Inspect
Command: `consul snapshot inspect`
The `snapshot inspect` command is used to inspect an atomic, point-in-time
snapshot of the state of the Consul servers which includes key/value entries,
service catalog, prepared queries, sessions, and ACLs. The snapshot is read
from the given file.
-> Typically this is used with Consul self-contained Snapshot files obtained
using the [`consul snapshot`](/consul/commands/snapshot) command or [Snapshot
API](/consul/api-docs/snapshot#generate-snapshot). If the file provided is named
`state.bin` however, the command will assume it is a raw raft snapshot in a
Consul server data directory and will attempt to read it directly. The
`state.bin` file must still be in the same directory as it's associated
`meta.json` file. This is useful for debugging data on live servers without
making a complete new snapshot via the CLI or API first.
2020-04-07 18:55:19 +00:00
The following fields are displayed when inspecting a snapshot:
- `ID` - A unique ID for the snapshot, only used for differentiation purposes.
- `Size` - The size of the snapshot, in bytes.
- `Index` - The Raft index of the latest log entry in the snapshot.
- `Term` - The Raft term of the latest log entry in the snapshot.
- `Version` - The snapshot format version. This only refers to the structure of
the snapshot, not the data contained within.
- Each data type, size, and count within the read snapshot.
2020-04-07 18:55:19 +00:00
## Usage
Usage: `consul snapshot inspect [options] FILE`
#### Command Options
- `-kvdetails` - Provides information about space usage for KV data stored in Consul.
- `-kvdepth` - Adjusts the grouping levels of keys.
Can only be used with `-kvdetails`.
Default is `2`.
- `-kvfilter` - Only keys that match the specified key prefix
are included in the response.
Can only be used with `-kvdetails`.
- `-format` - Specifies an output format for the response.
Specify `pretty` (default) to format the response in a human-readable form
as shown in the examples below,
or specify `JSON` to format the response as JSON.
2020-04-07 18:55:19 +00:00
## Examples
To inspect a snapshot from the file "backup.snap":
2020-05-19 18:32:38 +00:00
```shell-session
2020-04-07 18:55:19 +00:00
$ consul snapshot inspect backup.snap
2020-11-05 16:31:36 +00:00
ID 2-12426-1604593650375
Size 17228
Index 12426
Term 2
Version 1
2020-11-05 16:31:36 +00:00
Type Count Size
---- ---- ----
KVS 27 12.3KB
Register 5 3.4KB
Index 11 285B
Autopilot 1 199B
Session 1 199B
CoordinateBatchUpdate 1 166B
Tombstone 2 146B
FederationState 1 139B
ChunkingState 1 12B
---- ---- ----
Total 16.8KB
```
2020-11-05 16:31:36 +00:00
To get more details for a snapshot inspection from "backup.snap":
```shell-session
2020-11-10 17:22:45 +00:00
$ consul snapshot inspect -kvdetails -kvdepth 3 -kvfilter vault/core backup.snap
2020-11-05 16:31:36 +00:00
ID 2-12426-1604593650375
Size 17228
Index 12426
Term 2
Version 1
Type Count Size
---- ---- ----
KVS 27 12.3KB
Register 5 3.4KB
Index 11 285B
Autopilot 1 199B
Session 1 199B
CoordinateBatchUpdate 1 166B
Tombstone 2 146B
FederationState 1 139B
ChunkingState 1 12B
---- ---- ----
Total 16.8KB
Key Name Count Size
---- ---- ----
vault/core/leader 1 1.6KB
vault/core/mounts 1 675B
vault/core/wrapping 1 633B
vault/core/local-mounts 1 450B
vault/core/auth 1 423B
vault/core/cluster 2 388B
vault/core/keyring 1 320B
vault/core/master 1 237B
vault/core/seal-config 1 211B
vault/core/hsm 1 189B
vault/core/local-audit 1 185B
vault/core/local-auth 1 183B
vault/core/audit 1 179B
vault/core/lock 1 170B
vault/core/shamir-kek 1 159B
---- ---- ----
Total 5.9KB
2020-04-07 18:55:19 +00:00
```
Please see the [HTTP API](/consul/api-docs/snapshot) documentation for
more details about snapshot internals.
To inspect an internal snapshot directly from a Consul server data directory:
```shell-session
$ consul snapshot inspect /opt/consul/raft/snapshots/9-4600669-1618935304715/state.bin
ID 9-4600669-1618935304715
Size 4625420898
Index 4600669
Term 9
Version 1
Type Count Size
---- ---- ----
KVS 4089785 4.3GB
Register 9 5.2KB
CoordinateBatchUpdate 3 465B
Index 8 224B
Autopilot 1 199B
FederationState 1 139B
ChunkingState 1 12B
---- ---- ----
Total 4.3GB
```