---
title: "Facets"
---

> 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.

# Facets

Path: Logbrook API › Logs

`GET /indexes/{index}/logs/facets`

Returns value counts per field for the matching events.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `index` (`getLogFacets.path.index`; string, required) — Index name: lowercase letters, digits, underscores and hyphens. The token's index scope applies as well as its source scope.
  - minLength 1; maxLength 63; pattern `^[a-z0-9][a-z0-9_-]*$`

## Query parameters

- `from` (`getLogFacets.query.from`; integer, required) — Inclusive Unix milliseconds
- `to` (`getLogFacets.query.to`; integer, required) — Exclusive Unix milliseconds
- `source` (`getLogFacets.query.source`; string, optional) — Comma-separated sources. Defaults to every source the token can read.
- `service` (`getLogFacets.query.service`; string, optional) — Exact service
- `logger` (`getLogFacets.query.logger`; string, optional) — Exact logger
- `host` (`getLogFacets.query.host`; string, optional) — Exact host
- `message` (`getLogFacets.query.message`; string, optional) — Literal message substring
- `min_level` (`getLogFacets.query.min_level`; integer, optional) — Minimum numeric severity
- `filter` (`getLogFacets.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>/indexes/payments/logs/facets?from=1794297360000&to=1794297480000' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = '<base-url>/indexes/payments/logs/facets?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>/indexes/payments/logs/facets?from=1794297360000&to=1794297480000"

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

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

print(response.text)
```

## Responses

### 200

Successful response

#### Example

```json
{
  "services": [
    {
      "value": "checkout-api",
      "count": 4
    }
  ],
  "loggers": [
    {
      "value": "payments",
      "count": 3
    },
    {
      "value": "refunds",
      "count": 1
    }
  ],
  "hosts": [
    {
      "value": "web-1",
      "count": 2
    },
    {
      "value": "web-2",
      "count": 2
    }
  ],
  "levels": [
    {
      "value": "30",
      "count": 2
    },
    {
      "value": "40",
      "count": 1
    },
    {
      "value": "50",
      "count": 1
    }
  ],
  "sources": [
    {
      "value": "checkout",
      "count": 4
    }
  ]
}
```

- `services` (`getLogFacets.response.200.services`; array<object>, required)
  - `value` (`getLogFacets.response.200.services.value`; string, required)
  - `count` (`getLogFacets.response.200.services.count`; integer, required)
    - min 0
- `loggers` (`getLogFacets.response.200.loggers`; array<object>, required)
  - `value` (`getLogFacets.response.200.loggers.value`; string, required)
  - `count` (`getLogFacets.response.200.loggers.count`; integer, required)
    - min 0
- `hosts` (`getLogFacets.response.200.hosts`; array<object>, required)
  - `value` (`getLogFacets.response.200.hosts.value`; string, required)
  - `count` (`getLogFacets.response.200.hosts.count`; integer, required)
    - min 0
- `levels` (`getLogFacets.response.200.levels`; array<object>, required)
  - `value` (`getLogFacets.response.200.levels.value`; string, required)
  - `count` (`getLogFacets.response.200.levels.count`; integer, required)
    - min 0
- `sources` (`getLogFacets.response.200.sources`; array<object>, required)
  - `value` (`getLogFacets.response.200.sources.value`; string, required)
  - `count` (`getLogFacets.response.200.sources.count`; integer, required)
    - min 0

### 400

Invalid input

#### Example

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

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

### 401

Missing or invalid token

#### Example

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

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

### 403

Source outside read scope

#### Example

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

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

### 404

Index not found

#### Example

```json
{
  "error": "unknown index"
}
```

- `error` (`getLogFacets.response.404.error`; string, required)

### 413

Payload exceeds configured budget

#### Example

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

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

### 429

Capacity exhausted; Retry-After: 1

#### Example

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

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

### 503

Storage unavailable

#### Example

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

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

### 504

Query deadline expired

#### Example

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

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


Source: https://sandrinodm.github.io/logbrook/api/logs/facets/index.md
