Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ THIS SOFTWARE.


------------------------------------------------------------------------
yaml@2.8.4
yaml@2.9.0
License: ISC
Repository: https://github.com/eemeli/yaml
Publisher: Eemeli Aro <eemeli@gmail.com>
Expand Down
42 changes: 37 additions & 5 deletions docs/cli/configuration.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# Configuration
---
description: Configure the Elastic CLI by creating a config file with connection contexts for Elasticsearch, Kibana, and Elastic Cloud.
applies_to:
stack: preview
serverless: preview
type: how-to
---

# Configure the Elastic CLI

This guide covers the configuration file format, managing connection contexts with `elastic config`, and using external credential resolvers to keep secrets out of your config file.

## Before you begin

[Install the Elastic CLI](./installation.md) before continuing.

## Set up the config file

The CLI looks for a config file in your home directory. The following file names are checked in order:

Expand Down Expand Up @@ -35,7 +51,7 @@ contexts:

Multiple contexts are supported. Override `current_context` for a single command with `--use-context <name>`.

Each context can have any combination of service blocks (`elasticsearch`, `kibana`, `cloud`). Authentication supports `api_key` or `username` + `password`.
Each context can have any combination of service blocks (`elasticsearch`, `kibana`, and `cloud`). Authentication supports `api_key` or `username` + `password`.

## Authoring the config from the CLI

Expand Down Expand Up @@ -63,7 +79,17 @@ elastic config context edit local
elastic config context remove old-lab
```

If no OS keychain is available or you pass `--inline-secrets`, the secret is written inline and the file is `chmod 0600`. A warning is emitted when a loaded config has inline secrets at looser-than-0600 permissions.
If no OS keychain is available or you pass `--inline-secrets`, the secret is written inline and the file is `chmod 0600`. The CLI emits a warning when a loaded config has inline secrets at looser-than-0600 permissions.

## Verify your configuration

Run `elastic status` to check connectivity and authentication for all services in the active context:

```bash
elastic status
```

The command reports the result for each configured service (`elasticsearch`, `kibana`, `cloud`). Services not present in the active context are skipped, not treated as failures.

## Credential-safe project creation

Expand All @@ -82,14 +108,14 @@ elastic cloud serverless es projects reset-credentials --id <id> \
--save-as scratch --force
```

`--credentials-file <path>` writes a standalone YAML config fragment (0600) at `<path>` instead of mutating the main config. Either flag makes stdout safe to capture into an LLM transcript.
`--credentials-file <path>` writes a standalone YAML config fragment (0600) at `<path>` instead of mutating the main config. Both flags make stdout safe to capture into an LLM transcript.

## External credentials

Any string value in the config file can use `$(resolver:params)` expressions to fetch secrets from external sources at runtime.

:::{warning}
Review config files before using them if you didn't write them yourself. The `$(cmd:...)` and `$(file:...)` resolvers execute programs and read files on your behalf. This applies especially to CI/CD environments where a repo-checked-in config (e.g. via `ELASTIC_CLI_CONFIG_FILE`) can run arbitrary commands on the runner.
Review config files before using them if you didn't write them yourself. The `$(cmd:...)` and `$(file:...)` resolvers run programs and read files on your behalf. This applies especially to CI/CD environments where a repo-checked-in config (for example, via `ELASTIC_CLI_CONFIG_FILE`) can run arbitrary commands on the runner.
:::

`file`
Expand Down Expand Up @@ -164,3 +190,9 @@ elasticsearch:
auth:
api_key: $(keychain:elastic-cli/api-key)
```

## Next steps

- Run `elastic --help` to explore available commands.
- Use `elastic cloud serverless` or `elastic cloud hosted` to manage Elastic Cloud resources.
- See the [CLI command reference](./index.md) for the full list of available commands.
19 changes: 17 additions & 2 deletions docs/cli/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
Interact with the Elastic Stack and Elastic Cloud from the command line.
---
description: Use the Elastic CLI to interact with the Elastic Stack and Elastic Cloud from the command line.
applies_to:
stack: preview
serverless: preview
type: overview
---

Configure the CLI with `elastic config context add` to connect to your Elasticsearch, Kibana, and Elastic Cloud endpoints. See [Installation](./installation.md) and [Configuration](./configuration.md) to get started.
# Elastic CLI

The Elastic CLI (`elastic`) lets you manage Elasticsearch, Kibana, and Elastic Cloud resources from the command line. It supports both self-managed Elastic Stack deployments and Elastic Serverless projects.

Use the CLI to:
- Connect to multiple clusters or projects using named contexts
- Manage Elastic Cloud Hosted deployments and Serverless projects
- Automate operations in CI/CD pipelines and LLM agent workflows

To get started, see [Install the Elastic CLI](./installation.md) and [Configure the Elastic CLI](./configuration.md).
39 changes: 32 additions & 7 deletions docs/cli/installation.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
# Installation
---
description: Install the Elastic CLI globally with npm to run elastic commands from your terminal.
applies_to:
stack: preview
serverless: preview
type: how-to
---

Install globally from `npm` so the elastic binary is available on your `PATH`:
# Install the Elastic CLI

```bash
npm install -g @elastic/cli
elastic --help
```
## Before you begin

You need Node.js 22 or later and npm (included with Node.js) installed on your system. The CLI is tested on Linux, macOS, and Windows.

## Install globally

1. Install the `elastic` binary to your `PATH`:

```bash
npm install -g @elastic/cli
```

If you don't want a global install, you can run a one-off invocation with npx, which downloads and runs the CLI without persisting it:
2. Verify the installation:

```bash
elastic --version
```

## Run without installing

To run a one-off command without a permanent install, use `npx`:

```bash
npx -y @elastic/cli --help
```

## Next steps

- [Configure the Elastic CLI](./configuration.md) to connect to your Elasticsearch, Kibana, or Elastic Cloud endpoints.
13 changes: 13 additions & 0 deletions docs/cli/stack/es/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
description: Use the Elastic CLI to call Elasticsearch REST APIs from the command line.
applies_to:
stack: preview
serverless: preview
type: overview
---

# Elasticsearch commands

The `elastic stack es` command group exposes Elasticsearch REST APIs as CLI commands.

These commands are also available using the `elastic es` or `elastic elasticsearch` shortcuts.
13 changes: 13 additions & 0 deletions docs/cli/stack/kb/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
description: Use the Elastic CLI to call Kibana REST APIs from the command line.
applies_to:
stack: preview
serverless: preview
type: overview
---

# Kibana commands

The `elastic stack kb` command group exposes Kibana REST APIs as CLI commands.

These commands are also available using the `elastic kb` or `elastic kibana` shortcuts.
2 changes: 2 additions & 0 deletions docs/docset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ toc:
children:
- file: installation.md
- file: configuration.md
- file: stack/es/index.md
- file: stack/kb/index.md
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
description: Use the Elastic CLI to interact with the Elastic Stack and Elastic Cloud from the command line.
applies_to:
stack: preview
serverless: preview
type: overview
---

# Elastic CLI

Interact with the Elastic Stack and Elastic Cloud from the command line.
Loading