﻿---
title: stack kb alerting get-alerting-rule-id-query-inspector cli command
description: Get the Elasticsearch query for a rule Behaviour flags: --dry-run — validate all inputs and exit without performing any action 
url: https://www.elastic.co/elastic/docs-builder/docs/4083/reference/elastic-cli/cli/stack/kb/alerting/get-alerting-rule-id-query-inspector
applies_to:
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview
---

# stack kb alerting get-alerting-rule-id-query-inspector cli command
<cli-modifiers>
</cli-modifiers>

```bash
elastic stack kb alerting get-alerting-rule-id-query-inspector \
  --id <id> \
  [options]
```

Get the Elasticsearch query for a rule
**Behaviour flags:**
`--dry-run` — validate all inputs and exit without performing any action

## Options

<definitions>
  <definition term="--id string required">
    The identifier for the rule.
  </definition>
  <definition term="--mode enum">
    The inspection mode. Use "build" to return only the query, or "execute" to run the query and include the response.
    **Values:** build, execute
  </definition>
  <definition term="--alert-id string">
    The alert document ID. When provided, the query inspector uses the evaluation time range from the alert instead of the current time.
  </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>
</definitions>


## Global Options

<definitions>
  <definition term="--json">
    output as JSON
  </definition>
</definitions>