How to get keys by prefix

Guide to extracting etcd keys by their prefix

Pre-requisites

Get keys by prefix

1. $ etcdctl --endpoints=$ENDPOINTS get PREFIX --prefix

Global Options

1. --endpoints=[127.0.0.1:2379], gRPC endpoints

Options

1. --prefix, get a range of keys with matching prefix

Example

03_etcdctl_get_by_prefix_2016050501

1. etcdctl --endpoints=$ENDPOINTS put web1 value1
2. etcdctl --endpoints=$ENDPOINTS put web2 value2
3. etcdctl --endpoints=$ENDPOINTS put web3 value3

5. etcdctl --endpoints=$ENDPOINTS get web --prefix

Last modified June 24, 2025: etcd-website: reorganised tutorials to tasks (b5f1df7)