---
title: "Get the Elasticsearch query for a rule"
method: GET
path: "/api/alerting/rule/{id}/query_inspector"
tags: ["alerting"]
---

# Get the Elasticsearch query for a rule

`GET /api/alerting/rule/{id}/query_inspector`

**Spaces method and path for this operation:**

<div><span class="operation-verb get">get</span>&nbsp;<span class="operation-path">/s/{space_id}/api/alerting/rule/{id}/query_inspector</span></div>

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Returns the Elasticsearch query that a rule executes, and optionally its response.

## Path parameters

- `id` string, required

## Query parameters

- `mode` 'build' | 'execute'
- `alert_id` string

## Response `200`

Indicates a successful call.

- object
  - `queries` object[], required
    - `index` string, required
    - `label` string
    - `request` object, required
    - `response` object

## Other responses

- `400` — Indicates the rule type is not supported or the request parameters are invalid.
- `404` — Indicates a rule with the specified rule ID does not exist.

---

[API](https://skmtc.net/elastic/apis/kibana-apis.md) · [All operations](https://skmtc.net/elastic/apis/kibana-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/elastic/kibana-apis/versions/531c9e2a7d23/schema)
