---
title: "Search a CoreCluster's logs"
url: https://docs.corefinity.com/api/reference/logs/query-cluster-logs
type: endpoint
last_updated: 2026-11-13
feature: logs
related:
  - https://docs.corefinity.com/guides/sites/logs-and-monitoring/logs.md
  - https://docs.corefinity.com/mcp/tools/corecluster_logs_query.md
---
# Search a CoreCluster's logs

Answers the matching lines of every site of the CoreCluster that you can see, newest first, each with its
`site`; a query with a pipe answers `site` null and says so in `warnings`, and an aggregating pipe, such as
`| stats count()`, answers `kind` `table`. Paged by cursor: send `next_cursor` back as `cursor`; null means
the last page.

```http
POST /api/corestack/clusters/{cluster}/logs/query
```

- Scope: `read`
- Two-factor: required on your account (all)
- Rate limit: 150 a minute
- Try it in the console: on

## Path parameters

- `cluster` (integer, required): The id of a CoreCluster. Digits only.

## Body

- `environment` (string or null): `production` reads each site's production environment. `all` reads every environment. One of `production`, `all`, `null`. Defaults to `production`.
- `filters` (object or any or null): Filters applied beside the query.
- `from` (string or null): The start of the time range, as a date and time. It must be inside the time your logs are kept for.
- `query` (string or null): A LogsQL query, sent as written. Every line when left out. Up to 4 KB.
- `range` (string or any or null): How far back from now to read. One hour when neither `range` nor `from` is sent. Ignored when `from` is sent.
- `sites` (array of integers or null): The sites of this CoreCluster to read, by site row id. At most 200. Every site you can see when left out. A site that is not on this CoreCluster, or that you cannot see, answers `404`.
- `source` (string): A log source. `all` reads every source. `search` and `queue` exist only on platforms that run them; the sources list says which ones an environment has. One of `all`, `web-access`, `web-error`, `php`, `app`, `cron`, `database`, `cache`, `search`, `queue`. Defaults to `all`.
- `to` (string or null): The end of the time range, as a date and time. Now when left out.
- `cursor` (string or null): The `next_cursor` of the previous page, sent with the same request. A cursor from another request or another access token is refused `422` on `cursor`.
- `facets` (array of strings or string or any or null): Field names whose ten most frequent values to answer beside the lines, as a list or one comma-separated value.
- `limit` (integer or null): Lines a page. Defaults to `200`.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/clusters/1017/logs/query \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "environment": "all",
    "range": "1h"
  }'
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/clusters/1017/logs/query', [
        'environment' => 'all',
        'range' => '1h',
    ]);

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/clusters/1017/logs/query', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    environment: 'all',
    range: '1h',
  }),
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.post(
    "https://manage.corefinity.com/api/corestack/clusters/1017/logs/query",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "environment": "all",
        "range": "1h",
    },
)

data = res.json() if res.content else None
```

## Responses

### 200 A page of lines, or a table.

```json
{
  "effective_query": "status:>=500",
  "kind": "records",
  "lines": [
    {
      "fields": {
        "level": "error",
        "method": "GET",
        "src": "nginx-access",
        "status": 502
      },
      "msg": "GET /checkout 502",
      "site": {
        "environment": "Production",
        "id": 1042,
        "label": "harbourandfinch.example.com"
      },
      "source": "web-access",
      "stream_id": "00000001000000006754af9632a2745e85c293e5aac08633",
      "time": "2026-11-03T09:55:41.215Z"
    },
    {
      "fields": {
        "level": "error",
        "method": "GET",
        "src": "nginx-access",
        "status": 500
      },
      "msg": "GET /basket/3 500",
      "site": {
        "environment": "Production",
        "id": 1051,
        "label": "journal.harbourandfinch.example.com"
      },
      "source": "web-access",
      "stream_id": "00000001000000003e23e8160039594a33894f6564e1b134",
      "time": "2026-11-03T09:53:00Z"
    }
  ],
  "next_cursor": null,
  "stats": {
    "duration_ms": 112
  },
  "table": null,
  "tenant": {
    "percent": 8,
    "quota_gb": 120,
    "retention_days": 30,
    "state": "ok",
    "stored_gb": 10
  },
  "truncated": false,
  "warnings": [],
  "window": {
    "from": "2026-11-03T09:00:00.000000000Z",
    "to": "2026-11-03T10:00:00.000000000Z"
  }
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the scope (`scope_required`, with the `scope` to use), your company requires two-factor authentication and you have not set it up, or your account has no company that can use Managed Clusters, for example because the company was closed (`company_unavailable` or `company_not_enabled`, whichever the route checks first). For Managed Clusters routes; any other route uses `ForbiddenScopeOrTwoFactor`.

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist or is something you cannot see, or the feature is not on for your company (`feature_off`).

```json
{
  "code": "feature_off",
  "message": "Not found.",
  "reason": "feature_off"
}
```

### 409 The read cannot be made. `reason` says why: `logs_not_collected` (logs are not collected for this CoreCluster, or for any site of the read, yet), `logs_unavailable` (this source starts once the sites' next platform update has applied), `logs_range` (`from` is before the time your logs are kept for), `query_too_wide` (the query reads too much, or covers too many sites at once) or `logs_scope_split` (the sites keep their logs in different places: choose fewer sites).

```json
{
  "code": "logs_not_collected",
  "message": "Logs are not being collected for this environment yet",
  "reason": "logs_not_collected"
}
```

### 422 A field is missing or wrong. `field` names the first one and `errors` lists every one. Beside the request's own fields, `errors` can name `query` (the LogsQL is not valid, is over 4 KB, uses the `stream_context` pipe or the `time_offset` option, or is an aggregating query sent to an export), `filters.<name>` (a filter is not valid), `filters_max` (too many text or field filters), `cursor` (the cursor is not this request's or this token's) and `saved_max` (you already keep 50 saved queries).

```json
{
  "code": "invalid",
  "errors": {
    "query": [
      "Keep the query under 4 KB."
    ]
  },
  "field": "query",
  "message": "Keep the query under 4 KB.",
  "reason": "invalid"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

### 503 The logs store did not answer (`logs_cluster_unavailable`), or it is serving as many reads as it can (`logs_busy`, with `Retry-After`). The request itself is fine: try again shortly.

```json
{
  "code": "logs_busy",
  "message": "Logs are busy at the moment. Try again in a few seconds",
  "reason": "logs_busy"
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 404 | `feature_off` | This feature is not on for your organisation yet. |
| 409 | `logs_not_collected` | Logs are not being collected for the environment yet. Try again later, or contact support. |
| 409 | `logs_range` | The time range is outside the days logs are kept for. Choose a range inside the days the message names. |
| 409 | `logs_scope_split` | These sites keep their logs in different places. Choose a cluster or site. |
| 409 | `query_too_wide` | The search covers too much. Choose a shorter range or a narrower search. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 503 | `logs_busy` | Logs are busy at the moment. Try again in a few seconds. |
| 503 | `logs_cluster_unavailable` | Logs are not available at the moment. Try again shortly. |

## The same task elsewhere

- Guide: [Logs](https://docs.corefinity.com/guides/sites/logs-and-monitoring/logs.md)
- MCP tool: [`corecluster_logs_query`](https://docs.corefinity.com/mcp/tools/corecluster_logs_query.md)
