---
title: "Count events in the default index"
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/logbrook/llms.txt
> Use this file to discover all available pages before exploring further.

# Count events in the default index

Path: Logbrook API › Default index

`GET /logs/count`

Returns the number of matching events.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Query parameters

- `from` (`countDefaultLogs.query.from`; integer, required) — Inclusive Unix milliseconds
- `to` (`countDefaultLogs.query.to`; integer, required) — Exclusive Unix milliseconds
- `source` (`countDefaultLogs.query.source`; string, optional) — Comma-separated sources. Defaults to every source the token can read.
- `service` (`countDefaultLogs.query.service`; string, optional) — Exact service
- `logger` (`countDefaultLogs.query.logger`; string, optional) — Exact logger
- `host` (`countDefaultLogs.query.host`; string, optional) — Exact host
- `message` (`countDefaultLogs.query.message`; string, optional) — Literal message substring
- `min_level` (`countDefaultLogs.query.min_level`; integer, optional) — Minimum numeric severity
- `filter` (`countDefaultLogs.query.filter`; unknown, optional) — URL-encoded JSON, at most 4096 bytes decoded. Exact, typed matches on top-level attributes; every condition must match, along with the other filters. Missing and null values never match. Duplicate or unknown members and conflicting conditions return `400`. The request path and query together are limited to 32768 bytes.

## Code samples

### cURL

```bash
curl --request GET \
  --url '<base-url>/logs/count?from=1794297360000&to=1794297480000' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = '<base-url>/logs/count?from=1794297360000&to=1794297480000';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/logs/count?from=1794297360000&to=1794297480000"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
```

## Responses

### 200

Successful response

#### Example

```json
{
  "count": 4
}
```

- `count` (`countDefaultLogs.response.200.count`; integer, required)
  - min 0

### 400

Invalid input

#### Example

```json
{
  "error": "invalid or excessive half-open time range"
}
```

- `error` (`countDefaultLogs.response.400.error`; string, required)

### 401

Missing or invalid token

#### Example

```json
{
  "error": "Bearer token required"
}
```

- `error` (`countDefaultLogs.response.401.error`; string, required)

### 403

Source outside read scope

#### Example

```json
{
  "error": "source outside read scope"
}
```

- `error` (`countDefaultLogs.response.403.error`; string, required)

### 413

Payload exceeds configured budget

#### Example

```json
{
  "error": "query response exceeds byte budget"
}
```

- `error` (`countDefaultLogs.response.413.error`; string, required)

### 429

Capacity exhausted; Retry-After: 1

#### Example

```json
{
  "error": "HTTP capacity exhausted"
}
```

- `error` (`countDefaultLogs.response.429.error`; string, required)

### 503

Storage unavailable

#### Example

```json
{
  "error": "storage unavailable"
}
```

- `error` (`countDefaultLogs.response.503.error`; string, required)

### 504

Query deadline expired

#### Example

```json
{
  "error": "query deadline exceeded"
}
```

- `error` (`countDefaultLogs.response.504.error`; string, required)


Source: https://sandrinodm.github.io/logbrook/api/default-index/count/index.md
