# Query Monitors Summary

### Endpoint

**POST** `/api/monitors/summary/query`

### Authentication

This endpoint requires API Key authentication via the Authorization header.

### Headers

```bash
Authorization: Bearer <YOUR_API_KEY>
Content-Type: application/json
Accept: text/event-stream
```

### Request Body

The request body supports filtering, pagination, sorting, and time range parameters:

```json
{
  "conditions": [],
  "limit": 200,
  "skip": 0,
  "maxInstances": 10,
  "order": "desc",
  "sortBy": "lastFiringStart",
  "start": "2025-10-12T08:19:18.582Z",
  "end": "2025-10-12T09:19:18.582Z"
}
```

#### Request Parameters

| Parameter      | Type    | Required | Description                                                       |
| -------------- | ------- | -------- | ----------------------------------------------------------------- |
| `conditions`   | array   | No       | Array of filter conditions for monitors (empty array returns all) |
| `limit`        | integer | No       | Maximum number of monitors to return (default: 200)               |
| `skip`         | integer | No       | Number of monitors to skip for pagination (default: 0)            |
| `maxInstances` | integer | No       | Maximum instances per monitor result (default: 10)                |
| `order`        | string  | No       | Sort order: `"asc"` or `"desc"` (default: `"desc"`)               |
| `sortBy`       | string  | No       | Field to sort by (see sorting options below)                      |
| `start`        | string  | No       | Start time for filtering (ISO 8601 format)                        |
| `end`          | string  | No       | End time for filtering (ISO 8601 format)                          |

#### Sorting Options

| Sort Field          | Description                             |
| ------------------- | --------------------------------------- |
| `"lastFiringStart"` | Last time monitor started firing alerts |
| `"title"`           | Monitor title alphabetically            |
| `"severity"`        | Monitor severity level                  |
| `"createdAt"`       | Monitor creation date                   |
| `"updatedAt"`       | Last modification date                  |
| `"state"`           | Current monitor state                   |

#### Filter Conditions

The `conditions` array accepts filter objects for targeted monitor queries:

```json
{
  "conditions": [
    {
      "field": "severity",
      "operator": "equals",
      "value": "S1"
    },
    {
      "field": "state",
      "operator": "in",
      "values": ["Alerting", "Normal"]
    }
  ]
}
```

### Response

{% hint style="info" %}
The summary endpoint returns a **flattened projection** of each monitor that includes a few legacy top-level aliases (`header`, `resourceLabels`, `contextLabels`, `trigger`, `reducer`) alongside the modern nested `model` object. These aliases are retained for backwards compatibility with older list-view clients. The canonical authoring contract lives in [Monitor YAML structure](/use-groundcover/monitors/monitor-yaml-structure.md) and is what the [Get Monitor](/use-groundcover/remote-access-and-apis/api-examples/get-monitor.md) endpoint returns.
{% endhint %}

The endpoint returns a JSON object containing an array of detailed monitor configurations:

```json
{
  "hasMonitors": true,
  "monitors": [
    {
      "uuid": "string",
      "title": "string",
      "description": "string",
      "severity": "string",
      "measurementType": "string",
      "state": "string",
      "alertingCount": 0,
      "model": {
        "queries": [],
        "thresholds": []
      },
      "interval": {
        "interval": "string",
        "for": "string"
      },
      "executionErrorState": "string",
      "noDataState": "string",
      "isPaused": false,
      "createdBy": 0,
      "createdByEmail": "string",
      "createdAt": "string",
      "updatedAt": "string",
      "lastStateStart": "string",
      "lastFiringStart": "string",
      "firstFiringStart": "string",
      "lastResolved": "string",
      "minEvaluationDurationSeconds": 0.0,
      "avgEvaluationDurationSeconds": 0.0,
      "maxEvaluationDurationSeconds": 0.0,
      "lastEvaluationError": "string",
      "lastEvaluationTimestamp": "string",
      "silenced": false,
      "fullySilenced": false,
      "silence_uuids": []
    }
  ]
}
```

#### Response Fields

**Top-Level Fields**

| Field         | Type    | Description                              |
| ------------- | ------- | ---------------------------------------- |
| `hasMonitors` | boolean | Whether any monitors exist in the system |
| `monitors`    | array   | Array of monitor configuration objects   |

**Monitor Object Fields**

| Field                          | Type    | Description                                                  |
| ------------------------------ | ------- | ------------------------------------------------------------ |
| `uuid`                         | string  | Unique monitor identifier                                    |
| `title`                        | string  | Monitor display name                                         |
| `description`                  | string  | Monitor description                                          |
| `severity`                     | string  | Alert severity level (`"S1"`, `"S2"`, `"S3"`, `"S4"`)        |
| `measurementType`              | string  | Monitor type (`"state"`, `"event"`)                          |
| `state`                        | string  | Current monitor state (`"Normal"`, `"Alerting"`, `"Paused"`) |
| `alertingCount`                | integer | Number of active alerts                                      |
| `model`                        | object  | Monitor configuration with queries and thresholds            |
| `interval`                     | object  | Evaluation timing configuration                              |
| `executionErrorState`          | string  | State when execution fails                                   |
| `noDataState`                  | string  | State when no data is available                              |
| `isPaused`                     | boolean | Whether monitor is currently paused                          |
| `createdBy`                    | integer | Creator user ID                                              |
| `createdByEmail`               | string  | Creator email address                                        |
| `createdAt`                    | string  | Creation timestamp (ISO 8601)                                |
| `updatedAt`                    | string  | Last update timestamp (ISO 8601)                             |
| `lastStateStart`               | string  | When current state began                                     |
| `lastFiringStart`              | string  | When monitor last started alerting                           |
| `firstFiringStart`             | string  | When monitor first started alerting                          |
| `lastResolved`                 | string  | When monitor was last resolved                               |
| `minEvaluationDurationSeconds` | float   | Fastest query execution time                                 |
| `avgEvaluationDurationSeconds` | float   | Average query execution time                                 |
| `maxEvaluationDurationSeconds` | float   | Slowest query execution time                                 |
| `lastEvaluationError`          | string  | Last execution error message                                 |
| `lastEvaluationTimestamp`      | string  | Last evaluation timestamp                                    |
| `silenced`                     | boolean | Whether monitor is silenced                                  |
| `fullySilenced`                | boolean | Whether monitor is completely silenced                       |
| `silence_uuids`                | array   | Array of silence rule identifiers                            |

### Examples

#### Basic Request

Get all monitors with default pagination:

```bash
curl -L \
  --request POST \
  --url 'https://api.groundcover.com/api/monitors/summary/query' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --header 'Accept: text/event-stream' \
  --data-raw '{
    "conditions": [],
    "limit": 200,
    "skip": 0,
    "maxInstances": 10,
    "order": "desc",
    "sortBy": "lastFiringStart"
  }'
```

#### Filter by Time Range

Get monitors within a specific time window:

```bash
curl -L \
  --request POST \
  --url 'https://api.groundcover.com/api/monitors/summary/query' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --header 'Accept: text/event-stream' \
  --data-raw '{
    "conditions": [],
    "limit": 100,
    "skip": 0,
    "maxInstances": 10,
    "order": "desc",
    "sortBy": "lastFiringStart",
    "start": "2025-10-12T08:00:00.000Z",
    "end": "2025-10-12T10:00:00.000Z"
  }'
```

#### Pagination Example

Get the second page of results:

```bash
curl -L \
  --request POST \
  --url 'https://api.groundcover.com/api/monitors/summary/query' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --header 'Accept: text/event-stream' \
  --data-raw '{
    "conditions": [],
    "limit": 50,
    "skip": 50,
    "maxInstances": 10,
    "order": "desc",
    "sortBy": "title"
  }'
```

#### Sort by Creation Date

Get monitors sorted by newest first:

```bash
curl -L \
  --request POST \
  --url 'https://api.groundcover.com/api/monitors/summary/query' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --header 'Accept: text/event-stream' \
  --data-raw '{
    "conditions": [],
    "limit": 100,
    "skip": 0,
    "maxInstances": 10,
    "order": "desc",
    "sortBy": "createdAt"
  }'
```

#### Response Example

```json
{
  "hasMonitors": true,
  "monitors": [
    {
      "uuid": "12345678-1234-1234-1234-123456789abc",
      "title": "Example_Latency_Monitor",
      "description": "",
      "template": "Example_Latency_Monitor",
      "severity": "S2",
      "measurementType": "event",
      "header": "Example_Latency_Monitor",
      "resourceLabels": ["workload"],
      "contextLabels": ["namespace", "cluster"],
      "category": "",
      "interval": {
        "interval": "5m0s",
        "for": "1m0s"
      },
      "model": {
        "queries": [
          {
            "name": "threshold_input_query",
            "dataType": "traces",
            "expression": "status_code:>=500 | stats by (workload, namespace, cluster) count() as traces_total",
            "instantRollup": "5 minutes"
          }
        ],
        "reducers": null,
        "thresholds": [
          {
            "name": "threshold_1",
            "inputName": "threshold_input_query",
            "operator": "gt",
            "values": [502]
          }
        ],
        "type": "traces"
      },
      "reducer": "",
      "trigger": {
        "op": "gt",
        "value": 502
      },
      "labelsMapping": {
        "owner": "example-user"
      },
      "executionErrorState": "",
      "noDataState": "OK",
      "isPaused": false,
      "createdBy": 12345,
      "createdByEmail": "user@example.com",
      "createdAt": "2025-03-14T20:42:36.949847Z",
      "updatedAt": "2025-09-21T12:17:00.130801Z",
      "relativeTimerange": {},
      "silences": [],
      "monitorId": "12345678-1234-1234-1234-123456789abc",
      "state": "Alerting",
      "lastStateStart": "0001-01-01T00:00:00Z",
      "lastFiringStart": null,
      "firstFiringStart": null,
      "lastResolved": null,
      "alertingCount": 11,
      "silenced": false,
      "fullySilenced": false,
      "silence_uuids": [],
      "minEvaluationDurationSeconds": 7.107210216,
      "avgEvaluationDurationSeconds": 7.1096896183047775,
      "maxEvaluationDurationSeconds": 7.119120884,
      "lastEvaluationError": "",
      "lastEvaluationTimestamp": "2025-10-12T09:15:50Z"
    }
  ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groundcover.com/use-groundcover/remote-access-and-apis/api-examples/query-monitors-summary.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
