﻿---
title: stack es helpers watch cli command
description: Watch an index for new documents and stream them to stdout as NDJSON. Behaviour flags: --dry-run — validate all inputs and exit without performing any...
url: https://www.elastic.co/elastic/docs-builder/docs/4850/reference/elastic-cli/cli/stack/es/helpers/watch
applies_to:
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview
---

# stack es helpers watch cli command
<cli-modifiers>
</cli-modifiers>

```bash
elastic stack es helpers watch --index <index> [options]
```

Watch an index for new documents and stream them to stdout as NDJSON.
**Behaviour flags:**
`--dry-run` — validate all inputs and exit without performing any action

## Options

<definitions>
  <definition term="--index string required">
    Index or data stream to watch
  </definition>
  <definition term="--query string">
    Query DSL clause as JSON (wrapped under "query"), e.g. '{"match":{"log.level":"error"}}'
  </definition>
  <definition term="--query-file string">
    Path to a file containing the full search body JSON
  </definition>
  <definition term="--sort-field string">
    Field to use for ordering and detecting new documents
    **Default:** `@timestamp`
  </definition>
  <definition term="--poll-interval number">
    Polling interval in milliseconds
    **Default:** `5000`
  </definition>
  <definition term="--from string">
    ISO 8601 timestamp to start from (e.g. "2024-01-01T00:00:00Z"). Defaults to the most recent document.
  </definition>
  <definition term="--size number">
    Maximum documents to fetch per poll
    **Default:** `100`
  </definition>
  <definition term="--format string">
    Output template with {field} placeholders, e.g. "{@timestamp} {message}". Omit for NDJSON (_source as JSON).
  </definition>
  <definition term="--input-file string">
    path to a JSON file to use as command input
  </definition>
  <definition term="--dry-run">
    validate all inputs and exit without performing any action (preview changes without applying them)
  </definition>
  <definition term="--no-validate">
    skip input validation and send the request as-is
  </definition>
</definitions>


## Global Options

<definitions>
  <definition term="--output-fields string">
    comma-separated list of fields to include in output (dot-notation supported)
  </definition>
  <definition term="--output-template string">
    Mustache-like template for custom text output (e.g. "{{id}}: {{name}}")
  </definition>
  <definition term="--json">
    output as JSON
  </definition>
</definitions>