How to watch keys

Guide to watching etcd keys

Prerequisites

Watching keys

watch to get notified of future changes:

1. etcdctl watch $KEY [$END_KEY]

Options

1. -i, --interactive[=false]: interactive mode
2. --prefix[=false]: watch on a prefix if prefix is set
3. --rev=0: Revision to start watching
4. --prev-kv[=false]: get the previous key-value pair before the event happens
5. --progress-notify[=false]: get periodic watch progress notification from server

Options inherited from parent commands

1. --endpoints="127.0.0.1:2379": gRPC endpoints

Examples

06_etcdctl_watch_2016050501

1. etcdctl --endpoints=$ENDPOINTS watch stock1
2. etcdctl --endpoints=$ENDPOINTS put stock1 1000

4. etcdctl --endpoints=$ENDPOINTS watch stock --prefix
5. etcdctl --endpoints=$ENDPOINTS put stock1 10
6. etcdctl --endpoints=$ENDPOINTS put stock2 20

Last modified July 8, 2025: etcd-website: move how to watch keys from operator to developer task (64438da)