Skip to content
Merged
28 changes: 14 additions & 14 deletions CLAUDE.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Your apps send errors and logs with the official Sentry SDKs: just give the SDK
- **Users and roles**, each user limited to their projects.
- **MCP server** for coding agents (Claude Code, Codex, …) and a **REST API**.
- **Keeps its size:** under `MAX_DATABASE_SIZE` the least useful data is deleted first; passwords and tokens are removed from incoming data.
- **Small:** one container of about 20 MB.
- **Small:** one container of about 25 MB.

## Quick start

<!-- docker-run -->
```sh
docker run -d --name exceptic -p 8000:8000 -v exceptic-data:/data \
docker run -d --name exceptic -p 8000:8000 -v exceptic-data:/data --memory 512m --stop-timeout 30 \
-e ADMIN_PASSWORD='<at least 12 characters>' \
devforth/exceptic:latest
```
Expand All @@ -37,7 +37,7 @@ Install the Sentry SDK of your platform and give it the project's DSN, e.g. for
import * as Sentry from "@sentry/node";

Sentry.init({
dsn: "https://<public_key>@errors.example.com/1",
dsn: "https://<key>@errors.example.com/<project id>",
enableLogs: true,
});
```
Expand Down Expand Up @@ -78,7 +78,7 @@ make docker image-size # build the image and check its size

Notes on the Sentry envelope format: [docs/sentry-protocol.md](docs/sentry-protocol.md).

`make release` publishes the next version (from the `feat:`/`fix:` commits since the last tag, or `VERSION=X.Y.Z`) of the image `devforth/exceptic` for amd64 and arm64 from `main` once its CI passed, with this machine's `docker login`, and tags the commit `vX.Y.Z` ([tools/release.sh](tools/release.sh)).
`make release` publishes the next version (from the commits since the last tag, or `VERSION=X.Y.Z`) of the image `devforth/exceptic` for amd64 and arm64 from `main` once its CI passed, with this machine's `docker login`, and tags the commit `vX.Y.Z` ([tools/release.sh](tools/release.sh)).

## License

Expand Down
9 changes: 2 additions & 7 deletions cmd/exceptic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ func run() error {
return err
}

config.LimitMemory()
memoryLimit, memorySource := config.LimitMemory()

logger := logging.New(os.Stderr, settings.LogFormat, settings.LogLevel)
logger.Info("memory limit", "mib", memoryLimit>>20, "from", memorySource)

ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)

Expand Down Expand Up @@ -208,12 +209,6 @@ func serverURL(settings *config.Config, address net.Addr) string {
// logRetention says at startup how the database is kept small, so a
// surprising deletion can be traced to the setting.
func logRetention(logger *slog.Logger, settings config.Retention) {
if settings.MaxDatabaseBytes == 0 {
logger.Info("retention", "max_database_size", "0 (nothing is deleted)")

return
}

logger.Info("retention", logging.Block, "max_database_size", config.FormatSize(settings.MaxDatabaseBytes),
"cleanup", fmt.Sprintf("from %d%% to %d%% of the data held, or when the files stay over %d%%", config.CleanupStartPercent, config.CleanupStopPercent, config.CleanupFilesPercent))
}
Expand Down
10 changes: 9 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ services:
exceptic:
image: devforth/exceptic:latest # in production pin X.Y (docs/deployment.md)
restart: unless-stopped
# Time to finish requests and write queued notifications before Docker kills it (default 10 s).
# Time to finish requests, write the queue held in memory to disk and send queued notifications before Docker kills it (default 10 s).
stop_grace_period: 30s
# 512 MB is all it needs; it sizes its memory and queue by this limit (docs/deployment.md, Resources).
mem_limit: 512m
ports:
# Only on this machine, for its reverse proxy. A try over plain http from elsewhere: "8000:8000" with an http PUBLIC_URL.
- "127.0.0.1:8000:8000"
env_file: .env
# Docker keeps container logs forever by default: at most 3 files of 10 MB.
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
volumes:
- data:/data

Expand Down
6 changes: 3 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The token sees every project. Status changes made with it show as "API token" in

- Each endpoint is `/api/v1/<name>`. Reads are `GET` with query parameters (`?project=backend&limit=50`); changes are `POST` with a JSON body.
- Lists return `{"items": [...], "next_cursor": "..."}`. Pass `cursor=<next_cursor>` for the next page. `limit` is 1–100, 20 by default.
- `project` takes ids (`1`) or names (`backend`), several at once too.
- `project` takes ids (`48213907`, the number at the end of the DSN) or names (`backend`), several at once too.
- Times are in UTC: `2026-11-11T10:00:00Z`.
- Errors are `{"error": "message"}` with a status: 400 wrong input, 401 wrong token, 403 address not allowed, 404 not found.
- Errors are `{"error": "message"}` with a status: 400 wrong input, 401 wrong or missing token (or no `API_TOKEN` set), 403 address not allowed, 404 not found, 405 wrong method, 413 a body over 64 KiB, 500 internal error.

## Endpoints

Expand All @@ -29,7 +29,7 @@ The same endpoints serve the REST API and the [MCP tools](mcp.md). Managing proj
| `GET list_issue_events` | all | ✓ | ✓ | `issue_id`, `cursor`, `limit` | `items` [`event_id`, `timestamp`, `level`, `environment`, `release`, `trace_id`, `received_at`], `next_cursor` | List the stored events of an issue, newest first: time, level, environment, release and trace ID. Pass an event_id to get_issue to read one. |
| `GET get_event` | all | ✓ | ✓ | `event_id`, `project` | text | Like get_issue, for an event ID the SDK reported to the application (with its project). |
| `GET list_logs` | all | ✓ | ✓ | `cursor`, `from_id`, `level`, `limit`, `offset`, `project`, `query`, `since`, `trace_id`, `until` | `items` [`id`, `time`, `project`, `level`, `body`, `trace_id`, `issue`], `next_cursor`, `stopped`, `searched_to` | Search logs, newest first. Pass trace_id (from get_issue) for the logs of one request or browser session. A search stops after 20s: then stopped is true, searched_to says how far back it got and next_cursor goes on from there; narrow it (since/until, project, level) rather than paging far. |
| `GET list_projects` | all | ✓ | ✓ | `cursor`, `limit` | `items` [`id`, `name`, `dsn`, `log_levels`, `paused`, `unresolved_issues`], `next_cursor` | List the monitored projects with their unresolved issue counts and DSNs (what a Sentry SDK is configured with to report to the project). Not needed before list_issues: issue rows name their project. |
| `GET list_projects` | all | ✓ | ✓ | `cursor`, `limit` | `items` [`id`, `name`, `dsn`, `log_levels`, `paused`, `unresolved_issues`, `dropped`], `next_cursor` | List the monitored projects with their unresolved issue counts, DSNs (what a Sentry SDK is configured with to report to the project) and the logs and events the server did not store since the first of them (dropped; missing when none was dropped for 7 days). Not needed before list_issues: issue rows name their project. |
| `POST update_issue_status` | all | ✓ | ✓ | `issue_ids`, `status`, `ignore_for`, `ignore_until_events` | `issues` [`id`, `project`, `title`, `location`, `level`, `status`, `event_count`, `not_stored`, `stored_events`, `first_seen`, `last_seen`, `resolved_at`, `ignored_until`, `ignore_events_left`, `mcp_reference`], `missing_issue_ids`, `forbidden_issue_ids` | Set the status of 1 to 100 issues in one atomic call: resolved (fixed, reopens if the error happens again), ignored (no notifications; for good, or until the time or number of events chosen when ignoring) or unresolved (still happening or not looked at yet). Returns the updated summaries. |
| `POST delete_issue` | admin | ✓ | ✓ | `issue_id` | `deleted` | Delete an issue with its events; if the error happens again it comes back as a new issue. Admins only. |
| `GET list_cleanups` | all | ✓ | | — | `start_percent`, `stop_percent`, `files_percent`, `stale_percent`, `compaction_attempts`, `kept`, `runs` [`id`, `project`, `started_at`, `status`, `limit`, `size_before`, `compacted`, `size_after`, `freed`, `before_files`, `arrived`, `size_now`, `files`, `stop`, `needed`, `deleted_steps`, `result`, `took`, `span`, `between`, `error`, `steps`, `compaction`] | The latest runs of the cleanup by size, newest first, with the time of every step they ran and what each deleted. |
Expand Down
17 changes: 7 additions & 10 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For local development copy [.env.example](../.env.example) to `.env.local`.
| `DATA_DIR` | `./data` (`/data` in the image) | Where the data is kept. Put it on a volume. |
| `PUBLIC_URL` | | The address users and apps reach the server at, e.g. `https://errors.example.com`. Used in DSNs, links in notifications and the MCP address. With `https://` the login works only over HTTPS. |
| `LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error`. `debug` logs every request and why an envelope was rejected. |
| `GOMEMLIMIT` | `200MiB` | Memory the server tries to stay under. |
| `GOMEMLIMIT` | 75% of the container's memory limit, else `200MiB` | Memory the server tries to stay under, in Go's units (`384MiB`, `1GiB`; `MB` and `GB` are refused). The start logs the value and where it came from. |
| `LOG_FORMAT` | `auto` | `auto` (colored in a terminal, logfmt elsewhere), `pretty`, `text` or `json`. |

## Projects
Expand Down Expand Up @@ -41,9 +41,7 @@ Projects are added on the Projects page (or by a coding agent with `create_proje
| `RATE_LIMIT_LOGS_PER_MINUTE` | `10000` | Logs a project may send per minute. Keep it at least `100`, the most logs the JavaScript SDK sends at once. `0` = no limit. |
| `RECORD_LOG_LEVELS` | `all` | Log levels to store: `fatal`, `error`, `warn`, `info`, `debug`, `trace`, or `all`/`none`. A project can choose its own. Errors of every level are always stored. |

What the server accepted waits in a queue until it is stored, up to 30% of `MAX_DATABASE_SIZE`. Once the queue is 50% full, each active project (connected or holding data, not paused) may fill only its part of it: the queue split by disk share and multiplied by 1.5: 2 projects at 100% may take 75% each, 4 take 37.5%, a project at 50% half as much as one at 100%. Every active project keeps at least 5% of the queue, and at least 20 MB. A project over its part is told to wait a few seconds (429) while the others are still accepted.

While a part of a compaction runs (seconds), the database takes nothing new: a request waits for it, at most 10 s, while at most 200 requests wait holding at most 32 MB, one project at most half of it unless it is the only one waiting; beyond that it is told to wait a few seconds (429).
What the server accepted waits in a queue until it is stored: in memory, up to 25% of the memory limit (`GOMEMLIMIT`) but no more than the limit leaves after the server's fixed buffers (176 MB: requests being read, envelopes being parsed, the database's cache and write buffers), and at least 20 MB: 24 MB at the default `200MiB`, 96 MB with `--memory 512m`. What does not fit goes to disk, up to 30% of `MAX_DATABASE_SIZE`, except while a compaction holds new writes. A stop writes what is in memory to disk, and it is stored at the next start; what was already being stored gets 15 more seconds, and what is not stored by then is lost (counted as dropped); a killed process (or one out of memory) loses what was in memory, and a power loss or an OS crash also loses up to a second of what was stored (writes reach the disk once a second). Once the queue (memory and disk) is 50% full, each active project (connected or holding data, not paused) may fill only its part of it: the queue split by disk share and multiplied by 1.5: 2 projects at 100% may take 75% each, 4 take 37.5%, a project at 50% half as much as one at 100%. Every active project keeps at least 5% of the queue. A project over its part is told to wait (429) while the others are still accepted; while a compaction holds new writes, the parts are of the queue in memory. A refused app waits as long as the server takes, at the rate it stored lately, to store what must make room for the envelope (a project over its part at its part of that rate): 1 to 30 seconds, 10 when nothing was stored in the last 10 seconds, and at least 10 while a compaction holds new writes.

### Size limits

Expand Down Expand Up @@ -72,13 +70,12 @@ Where notifications go is set on the **Notifications** page. Telegram and Slack

## Retention

Nothing is deleted by age. Data stays until the database nears its size limit.
Nothing is deleted by age: data stays until the database nears its size limit; only events turning a month old are thinned (below).

| Variable | Default | |
|---|---|---|
| `MAX_DATABASE_SIZE` | `2GB` | When the data reaches 90% of it, the least useful data is deleted until it is at 70%. If apps send faster than that, new logs are refused from 100% and new errors from 105%, until the cleanup catches up. Give the disk 1.4 times this: the most it can take, under a flood the data at the limit, new data waiting in the queue and deleted data not yet compacted. At least `500MB`; `0` turns the limit off. |
| `CLEANUP_HOLDS_INGEST` | | An experiment: `1` makes the cleanup's steps hold new data back while they delete; it waits in the queue and is stored after them. |
| `COMPACTION_HOLDS_INGEST` | `1` | `0` lets new data in while each part of a compaction runs; under a steady flow the compaction then goes on for as long as data comes, and the cleanup waits for it. |
| `MAX_DATABASE_SIZE` | `2GB` | When the data reaches 90% of it, the least useful data is deleted until it is at 70%. If apps send faster than that, new logs are refused from 100% and new errors from 105%, until the cleanup catches up. Under a flood the files exceed it for a while (deleted data not yet compacted), so give the disk more ([Resources](deployment.md#resources)). At least `500MB`. |
| `COMPACTION_HOLDS_INGEST` | `1` | While a compaction runs, new data waits in the queue (429 once it is full) and is stored when it ends. A compaction starts after a few seconds without new data (the one after a cleanup pauses between its parts when data comes again), unless the files pass 1.25 times `MAX_DATABASE_SIZE`. `0` lets new data be stored meanwhile; under a steady flow the compaction then goes on for as long as data comes, and the cleanup waits for it. |

The cleanup deletes in this order:

Expand All @@ -94,9 +91,9 @@ The cleanup deletes in this order:
10. The latest event of issues not seen for a week (the issue stays in the list).
11. Whole issues, longest unseen first.

The first three always run; the rest only until the data is back at 70%. The **Cleanup history** on the Projects page shows every run. Records a deleted issue left behind, which only a bug leaves, are removed apart from the cleanup, once an hour while nothing is being received.
The first three always run; the rest only until the data is back at 70%. The **Cleanup history** on the Projects page shows every run. Records a deleted issue left behind, which only a bug leaves, are removed apart from the cleanup, once an hour while nothing is being received, and at least once a day.

- Events older than a month keep the error and stack trace and lose the rest (breadcrumbs, request, tags).
- Events turning a month old keep the error and stack trace and lose the rest (breadcrumbs, request, tags), whatever the size.
- An issue stores at most 10 events a minute; the rest are only counted.
- A log message repeated many times keeps its newest 10 copies.
- The [audit log](ui.md#audit-log) is never deleted.
Expand Down
27 changes: 14 additions & 13 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,29 @@ server {

- Apps send errors to `/api/<project id>/envelope/`. It must stay reachable for them (and for browsers, if you monitor a frontend). It accepts only requests with the project's key.
- Limit the UI, REST API and MCP to your office or VPN with `ALLOWED_IPS`.
- Passwords, cookies and tokens are removed from incoming errors and logs before they are stored.
- Two roles: **admin** (everything: every project, users, settings, deleting) and **user** (issue statuses, logs, project DSNs and their own coding agents). A user sees only the projects given to them. Add users on the **Users** page: [Users](ui.md#users).
- Passwords, cookies and tokens are removed from incoming errors and logs before they are stored. The queue on disk keeps envelopes as the apps sent them until they are stored and the queue is compacted, and a backup taken meanwhile holds them too ([Ingest](configuration.md#ingest)).
- Two roles: **admin** (everything: every project, users, settings, deleting) and **user** (issue statuses, logs, projects, notifications and users within their projects, and their own coding agents; not deleting projects or data, nor disk shares). A user sees only the projects given to them. Add users on the **Users** page: [Users](ui.md#users).
- After 10 wrong passwords in 15 minutes a login is blocked until the window ends. Browsers the user logged in from before can still log in.

## Resources

| | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU for many busy projects |
| Memory | 256 MB | 512 MB |
| Disk | 1.4 × `MAX_DATABASE_SIZE` | the same, on an SSD |
| Memory | 512 MB | the same |
| Disk | 1.5 × `MAX_DATABASE_SIZE` (under a flood the files reached 1.4 times it: the queue on disk and deleted data not yet compacted), plus the backups kept in `/data/backups` | the same, on an SSD |

The server uses about 200 MB of memory whatever the load; more memory does not make it faster.
Give the container 512 MB: `compose.yml` sets `mem_limit: 512m`, with `docker run` add `--memory 512m`. The server sizes its memory and its queue by that limit, and needs no more; without a limit it keeps to a smaller default whatever the machine has ([`GOMEMLIMIT`](configuration.md#server), [Ingest](configuration.md#ingest)).

How much the server can take at most, by CPU: the most errors it stored while 10 projects sent them without pause through the official Node.js SDK. Each error was about 16 KB (a stack trace, 10 breadcrumbs, user, tags). Normal use is far below this.
How much the server can take at most, by CPU, in a 512 MB container: the most errors it stored while 10 processes of the official Node.js SDK sent them without pause. Each error was about 16 KB (a stack trace, 10 breadcrumbs, user, tags). Normal use is far below this.

| CPU | 0.5 | 1 | 2 | 4 |
|---|---|---|---|---|
| Errors a minute, all projects together | 8,300 | 16,700 | 26,500 | 39,400 |
| Data a minute | 130 MB | 265 MB | 415 MB | 620 MB |
| CPU | 2 | 4 |
|---|---|---|
| Errors a minute, all projects together | 35,600 | 54,100 |
| Data a minute | 555 MB | 845 MB |
| A full database, the cleanup deleting meanwhile | 19,900 errors, 310 MB | 31,500 errors, 490 MB |

Logs sent along take their share: with 5 logs per error, about a third fewer errors.
Logs sent along take their share: with 5 logs per error, about a quarter fewer errors.

Above that, apps pause for a few seconds and then send again. What they drop meanwhile shows on the Projects page. A project that sends more than its part of the queue is paused alone ([Ingest](configuration.md#ingest)).

Expand Down Expand Up @@ -134,7 +135,7 @@ docker compose pull && docker compose up -d

This brings the newest patch of your `X.Y`. For a new minor version change the tag first.

On stop the server sends the notifications still waiting. `compose.yml` gives it 30 s for that; with `docker run` add `--stop-timeout 30`.
On stop the server finishes the requests in progress, writes the queue it holds in memory to disk ([Ingest](configuration.md#ingest)) and sends the notifications still waiting. `compose.yml` gives it 30 s; with `docker run` add `--stop-timeout 30`.

## Sign in with Google

Expand All @@ -158,4 +159,4 @@ It prints a temporary password; the user chooses a new one at the next login.

## Logs

`docker compose logs -f` shows the settings at start, warnings and errors. `LOG_LEVEL=debug` also shows every request and why an app's data was rejected.
`docker compose logs -f` shows the settings at start, warnings and errors; more with [`LOG_LEVEL`](configuration.md#server). Docker keeps a container's logs until it is removed, so `compose.yml` keeps at most 3 files of 10 MB (`json-file`); with `docker run` add `--log-opt max-size=10m --log-opt max-file=3`.
Loading
Loading