# Dec 1st, 2026: \[EN\] The 12 days of Peek: 12 features of an interactive Elasticsearch CLI

**URL:** <https://discuss.elastic.co/t/dec-1st-2026-en-the-12-days-of-peek-12-features-of-an-interactive-elasticsearch-cli/391828>\
**Category:** Advent Calendar\
**Created:** [December 1, 2026, 8:00am UTC](https://discuss.elastic.co/t/dec-1st-2026-en-the-12-days-of-peek-12-features-of-an-interactive-elasticsearch-cli/391828 "2026-12-01T08:00:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quentin\_Pradet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quentin_pradet/32/94192_2.png) [@Quentin\_Pradet](https://discuss.elastic.co/u/Quentin_Pradet)\
**Post date:** [December 1, 2026, 8:00am UTC](https://discuss.elastic.co/t/dec-1st-2026-en-the-12-days-of-peek-12-features-of-an-interactive-elasticsearch-cli/391828/1 "2026-12-01T08:00:56Z")

</div>

_Ce post est également [disponible en français](https://discuss.elastic.co/t/392068)_

Welcome to the Elastic Advent Calendar! Today, we're going to talk about [Peek](https://github.com/ywangd/peek), an interactive CLI tool to explore an Elasticsearch instance.

While an Elastic employee maintains Peek, it's not an official Elastic product. It's also very different from the official [Elastic CLI](https://www.elastic.co/docs/reference/elastic-cli), which is meant for scripts and agents, not interactive human use. With that out of the way, let the fun begin!

To make things more interesting, we'll reuse the structure of [The Twelve Days of Christmas](https://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)), with illustrations [from Xavier Romero-Frias (CC BY-SA 3.0)](https://commons.wikimedia.org/wiki/Special:Redirect/page/23287278).

If you want to follow along, use [start-local](https://www.elastic.co/docs/deploy-manage/deploy/self-managed/local-development-installation-quickstart) to start Elasticsearch (and Kibana):

```bash
$ curl -fsSL https://elastic.co/start-local | sh

  ______ _ _ _
 | ____ | | | | (_)
 | | __| |__ _ ___| |_ ____
 | __| | |/ _` /__ | __| |/__ |
 | |____| | (_| \__ \ |_| | (__
 | ______|_|\__ ,_| ___/\__ |_|\___|
-------------------------------------------------
🚀 Run Elasticsearch and Kibana for local testing
-------------------------------------------------

ℹ️ Do not use this script in a production environment

⌛️ Setting up Elasticsearch and Kibana v9.5.7-arm64...

- Generated random passwords
- Created the elastic-start-local folder containing the files:
  - .env, with settings
  - docker-compose.yml, for Docker services
  - start/stop/uninstall commands
- Running docker compose up --wait

[...]

🎉 Congrats, Elasticsearch and Kibana are installed and running in Docker!

🌐 Open your browser at http://localhost:5601

   Username: elastic
   Password: [redacted]

🔌 Elasticsearch API endpoint: http://localhost:9200
🔑 API key: [redacted]

Learn more at https://github.com/elastic/start-local

```

## On the first day of Christmas, Peek gave to me: a Kibana-like Console in my terminal

 ![A partridge in a pear tree](https://us1.discourse-cdn.com/elastic/original/3X/e/a/ea97ad4a2ec7e09c899a2c9cbb8726943d529e7f.jpeg)

You can install Peek directly from [PyPI](https://pypi.org/project/es-peek/), using your favorite package manager. I recommend installing it as a tool with [uv](https://docs.astral.sh/uv/):

```auto
uv tool install es-peek

```

Now, start Peek, which will prompt you for your password: enter the one you got from start-local.

```bash
$ peek --hosts localhost:9200 --username elastic
Please enter password: ********

```

You can now send your first command. Blank line (or ESC+Enter) confirms.

```auto
>>> [0] elastic @ http://localhost:9200
GET /

=== took=9.952ms
{
  "name": "e7e408a664c9",
  "cluster_name": "docker-cluster",
  "cluster_uuid": "PDEH2qiNQ8SlJltrSh1TRg",
  "version": {
    "number": "9.5.7",
    "build_flavor": "default",
    "build_type": "docker",
    "build_hash": "d16690c781d994379d7d7be885c266543c2f6991",
    "build_date": "2026-11-19T00:34:54.990835033Z",
    "build_snapshot": false,
    "lucene_version": "10.5.2",
    "minimum_wire_compatibility_version": "8.19.0",
    "minimum_index_compatibility_version": "8.0.0"
  },
  "tagline": "You Know, for Search"
}

```

## On the second day: two modes of running

 ![Two turtle doves](https://us1.discourse-cdn.com/elastic/original/3X/2/2/22d215bd1c322d8b93bb5b242679c2822e7751dd.jpeg)

We've already seen the first mode of running: interactive queries. But Peek also supports batch mode:

- Inside a session, you can type `run 'setup.es'` to run a script containing queries.
- You can also directly run `peek --username elastic setup.es` or `cat setup.es | peek --username elastic`

## On the third day: three kinds of quotes

 ![Three French hens](https://us1.discourse-cdn.com/elastic/original/3X/9/2/924f1e433a01217747cc7ab38db3ffc18c1e4b71.jpeg)

Since Peek is meant mostly for human use, not scripts, it is flexible with quotes. You can use single quotes and double quotes:

```auto
// Index a single document
POST /my-index/_doc/1
{'foo': "bar"} // both single and double quotes are acceptable

```

More importantly, triple quotes are also allowed, which improves readability for characters that are usually escaped in JSON. They also improve compatibility with the Kibana Console, which supports them too.

```auto
// Execute an ES|QL query (triple quotes can be either ''' or """)
POST /_query?format=txt
{
  "query": """
    FROM my-index
    | WHERE foo == "bar"
    | LIMIT 10
  """
}

```

Additionally, Peek also allows `//` comments, trailing commas, and lowercase verbs:

```auto
>>> [0] elastic @ http://localhost:9200
post /_query?format=txt
{"query": "FROM my-index | LIMIT 10",} // trailing comma
=== took=12.950ms
      foo | foo.keyword
---------------+---------------
bar |bar

```

## On the fourth day: four calling options

 ![Four calling birds](https://us1.discourse-cdn.com/elastic/original/3X/8/2/829860205ed33afad456cb35ffb805e10acbdd4a.jpeg)

Peek documents four options on the query line:

```auto
// Run-AS and other headers
GET _security/_authenticate runas='foo' xoid='my-x-opaque-id' headers={'some-other-header': 'blah'}
// Choose a specific connection
get / conn=0 // send the request to the first connection (zero-based index)

```

See the [connections](https://peek.readthedocs.io/en/latest/usage.html#connection-and-session) docs for more details.

## On the fifth day: five golden keyrings

 ![Five golden rings](https://us1.discourse-cdn.com/elastic/original/3X/5/b/5ba597dde77e9b80051ccf3ae17584b16ec7e359.jpeg)

OK, not actually five: one keyring is enough. Peek keeps your password in the [system keyring on major operating systems](https://pypi.org/project/keyring/), so you don't have to type it twice. If it changed, use `--force_prompt` to update it.

## On the sixth day: six shortcuts a-saving

 ![Six geese a-laying](https://us1.discourse-cdn.com/elastic/original/3X/e/6/e60e307e24cc64a7a6593ce5d904168d41f1a61e.jpeg)

Peek supports most readline shortcuts such as `Ctrl-a`, `Ctrl-k`, `Ctrl-r`, and documents six shortcuts:

- `<F3>` - toggle formatting
- `<F12>` - toggle mouse support
- `ESC + Enter` - send the request
- `ESC + c` - Copy current input to system clipboard (this requires installing `es-peek[full]`).
- `ESC + a` - Go to the beginning of the current input buffer
- `ESC + e` - Go to the end of the current input buffer

## On the seventh day: seven ways of signing in

 ![Seven swans a-swimming](https://us1.discourse-cdn.com/elastic/original/3X/c/1/c1c4a2af193bd32df48d755162d80be5143e4c49.jpeg)

Peek supports:

- username and password
- [API key](https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys)
- [Elasticsearch tokens](https://www.elastic.co/docs/api/elasticsearch/operation/operation-security-get-token)
- [SAML](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/saml)
- [OpenID Connect](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/openid-connect)
- [Kerberos](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/kerberos) (with `es-peek[full]` install)
- [Public Key Infrastructure (PKI)](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/pki)

Fun fact: if you create an API key within Peek, type `connect` to use it from now on!

```auto
PUT _security/api_key
{"name": "advent-key"}

connect

```

## On the eighth day: eight clusters connected

 ![Eight maids a-milking](https://us1.discourse-cdn.com/elastic/original/3X/1/d/1d069cbdec20d66790da9311aecbc77a56a87511.jpeg)

You can connect to as many clusters as you want thanks to Peek's connection support:

```auto
connect hosts='localhost:9200' username='elastic'
connection rename='local'
connection // list them all
get / conn=0 // ask the first one without switching
session @save // keep them for next time

```

## On the ninth day: nine-dot-x completions

 ![Nine ladies dancing](https://us1.discourse-cdn.com/elastic/original/3X/1/9/1926301edecee6eb9b9317ceb3a85a3a4fd4bdd5.jpeg)

Run `_download_api_specs` to get 9.x autocompletion thanks to the [Elasticsearch specification](https://github.com/elastic/elasticsearch-specification). On an 8.x cluster, set `autocompletion_version = 8.19` in `peekrc` first.

## On the tenth day: ten thousand history entries

 ![Ten lords a-leaping](https://us1.discourse-cdn.com/elastic/original/3X/d/0/d071dea49f63b6f65c04c098bf49c6f532e7abcf.jpeg)

Peek keeps 10,000 history entries in an SQLite database. Ctrl-r works, but you can also use `history` to list past commands and `history 42` to run the 42nd entry.

## On the eleventh day: eleven pipers piping

 ![Eleven pipers piping](https://us1.discourse-cdn.com/elastic/original/3X/1/9/1903be89ef6b2e0ccb7a23aa0920f7e2d4f84837.jpeg)

Peek can run commands on responses with `pipe` or store the result in a file with `out`:

```auto
GET / pipe='jq .version.number'
GET /_cat/indices out='indices.txt'
!wc -l indices.txt

```

`@` allows loading a payload from an NDJSON file:

```javascript
POST /gifts/_bulk
@gifts.ndjson

```

## On the twelfth day: twelve docs a-drumming

 ![Twelve drummers drumming](https://us1.discourse-cdn.com/elastic/original/3X/e/7/e7902abe30ed7e9a6818f91133263b9c993d630c.jpeg)

Finally, Peek has a small scripting language! See it in action:

```auto
for i in range(0, 12) {
  PUT ("drummers/_doc/" + i)
  { "drummer": i, "bpm": randint(60, 180) }
}
GET drummers/_doc/11
echo _."_source"."bpm"

```

(`_` holds the last response.)

## All together now

> On the twelfth day of Christmas, Peek gave to me:  
> twelve docs a-drumming,  
> eleven pipers piping,  
> ten thousand history entries,  
> nine-dot-x completions,  
> eight clusters connected,  
> seven ways of signing in,  
> six shortcuts a-saving,  
> five golden keyrings,  
> four calling options,  
> three kinds of quotes,  
> two modes of running,  
> and a Kibana-like Console in my terminal.

And if twelve gifts are not enough, extend Peek with your own gifts:

- Save this as ~/.config/peek/extensions/hello.py:

- Start Peek and type hello.

Type `help` to see everything, and read more in the [documentation](https://peek.readthedocs.io/).

Happy holidays, and happy peeking!
