Skip to content

Metrics API ​

A read-only JSON API for charting Lumberjack's data in Grafana or reading it from any HTTP client: requests, errors, latency, issues, jobs, queues, hosts, web vitals, releases and AI usage. It also serves the current gauges in the Prometheus text format, for scraping and alerting.

Authentication ​

  • A team token, sent as Authorization: Bearer lj_mcp_.... Create it under API and MCP tokens on the team page, as described in MCP. The token reads the projects it covers that its creator may see, where it may use get_metric_series. issues also needs list_issues in that project, and the AI metrics need get_ai_usage.
  • Public stats, without a header. An owner or admin turns on Public stats in a project's Settings, Keys. That creates a secret URL, https://your-lumberjack/api/v1/public/ps_.../, which serves the same endpoints for that one project. Rotating the URL stops the old one at once. Every change goes into the audit log.

Public stats show aggregates only. They leave out issue messages, stack traces, user ids, query strings and host names. Hosts show as host 1, host 2. Issue titles are left out unless Include issue titles is ticked. AI usage is never public: its series answer 422, and the summary and Prometheus page leave it out.

Paths below are relative to https://your-lumberjack/api/v1 with a token, or to the public stats URL without one.

Limits and errors ​

WhatLimit
Requests per token or public key120 a minute, then 429
Unknown tokens or keys per address30 a minute, then 429 for that minute
Time range of a seriesat most 90 days and 2,000 points
Freshnessanswers can be up to 30 seconds old
StatusWhen
401The token is wrong or missing.
403The token may not read issues, or AI usage, in this project.
404The public key is unknown, or the credential cannot read the project.
422A parameter is invalid.

Data past a project's retention is deleted and does not show.

Endpoints ​

EndpointReturns
GET /projectsThe projects the credential reads: uuid, slug, name.
GET /projects/{p}/summaryRequests, errors, error rate, p50/p95/p99, Apdex, open issues, users affected, job runs, failed and stuck jobs, health check counts, and the previous period's requests, errors, p95 and failed jobs. Under ai, the AI usage page's totals (see below), or null.
GET /projects/{p}/series/{metric}A time series, see below.
GET /projects/{p}/routesPer route: name, domain (with several), requests, p50/p95/p99, error rate, Apdex.
GET /projects/{p}/issuesOpen issues, last seen first: reference, title, status, occurrences, users.
GET /projects/{p}/jobsPer job class: runs, failures, failure rate, p50/p95 duration, p95 wait.
GET /projects/{p}/queuesPer queue: latest size, oldest age, p95 wait.
GET /projects/{p}/hostsPer agent: online, last seen, CPU load per core, memory and disk in use.
GET /projects/{p}/releasesRelease health: requests, error rate, p95, occurrences, new issues, regressions.
GET /metricsPrometheus text format of the current gauges of every project.

{p} is a project's slug or uuid. The summary and tables take:

ParameterValues
period1h, 24h (default), 7d or 30d, ending now
environmentOptional. Only this environment.
limitTables only. 100 by default, 50 for releases, at most 500.

Durations are in milliseconds, rates and shares are fractions from 0 to 1, and sizes are in bytes.

Tables come as typed columns and rows:

json
{
    "columns": [
        { "name": "method", "type": "string", "unit": null },
        { "name": "route", "type": "string", "unit": null },
        { "name": "requests", "type": "number", "unit": "count" },
        { "name": "p95", "type": "number", "unit": "ms" }
    ],
    "rows": [["GET", "/checkout", 1204, 412.5]]
}

Series ​

GET /projects/{p}/series/{metric}, where {metric} is one of:

MetricUnitSplits by
requests, errors (5xx)countenvironment, route, domain, release
error_rateratioenvironment, route, domain, release
p50, p95, p99msenvironment, route, domain, host, release
apdexscoreenvironment, route, domain, release
occurrences, userscountenvironment, host, release
new_issuescountenvironment, release
job_runs, job_failurescountenvironment, queue, host
queue_wait (p95)msenvironment, queue, host
queue_sizecountqueue, host
queue_workerscountqueue, host
cpu_load, memory_used, disk_usedratiohost
lcp_p75, inp_p75msenvironment, route, release
cls_p75scoreenvironment, route, release
db_sizebytesenvironment, check
db_connectionscountenvironment, check
db_connections_usedratioenvironment, check
activitycountenvironment, activity
ai_calls, ai_errorscountenvironment, provider, model, key, owner, actor
ai_tokens_input, ai_tokens_outputcountenvironment, provider, model, key, owner, actor
ai_tokens_cache_read, ai_tokens_cache_write, ai_tokens_reasoningcountenvironment, provider, model, key, owner, actor
ai_costcurrencyenvironment, provider, model, key, owner, actor, payer

Query parameters, which match Grafana's macros:

  • from, to: epoch milliseconds (${__from}, ${__to}) or ISO 8601. The last 24 hours by default.
  • interval: the bucket size, such as 30s, 5m, 1h or 1d (${__interval}), or auto (the default) for about 300 points. The interval is at least a minute, rounded up to whole minutes, and raised so a series has at most 2,000 points. The answer's interval says what was used.
  • environment, route, domain, queue, job, host, release, check, activity: filters. route, domain, queue, job, host, check (a health check's slug, such as database:pgsql) and activity (group:name, such as billing:invoice.paid) take * as a wildcard (/api/*, *.example.com). route matches a route's URI or its name (orders.*). A filter that does not apply to a metric is ignored, except host, which is rejected with 422.
  • provider, model, key, owner, actor, payer: filters of the AI metrics. provider and model take * as a wildcard (claude-*). key is a key's name or its short id, never its fingerprint. owner and actor are type:id, such as tenant:7. payer is us or customer and narrows ai_cost to that payer's share.
  • group_by: one series per environment, route, domain, host, queue, release, check, activity (as group:name), or for the AI metrics provider, model, key (its name, else its short id), owner, actor (both as type:id) or payer (us and customer). Only the busiest top are returned, 10 by default and at most 50.
json
{
    "metric": "p95",
    "unit": "ms",
    "interval": "5m",
    "from": "2026-11-03T10:00:00Z",
    "to": "2026-11-03T11:00:00Z",
    "points": [
        { "t": "2026-11-03T10:00:00Z", "series": "GET /checkout", "value": 412 }
    ]
}

In a bucket without data, counts are zero and other metrics have no point. Without group_by, series is the metric's name. ai_cost adds currency, the team's currency (ISO 4217, such as EUR).

How the numbers are counted ​

  • Request totals and error rates count every request, sampled or not. Percentiles and Apdex use only the sampled runs. See Sampling. With a release filter or split, totals are estimated from the sampled runs and their sample rate.
  • Apdex uses a 500 ms target, as on the Requests page.
  • cpu_load is the 1 minute load per core (1 is every core busy); memory and disk are the share in use. A host metric is the highest value over the hosts. A queue's size is the largest it reported in a bucket, summed over the queues.
  • The database metrics come from database health checks. Each check counts its largest figure in a bucket, summed over the checks. A database reported by several servers counts once. db_connections_used is connections over max_connections, the highest over the checks.
  • activity counts activity per hour when the interval is whole hours, so an hourly series reaches back as far as the hourly counts are kept. A shorter interval counts the activity itself, kept for less time. With hourly buckets, the first hour of the range counts whole.

AI usage ​

The ai_* metrics read the AI usage totals, so they agree with the AI pages:

  • They are counted per hour, so their interval is whole hours (5m becomes 1h) and the first hour of the range counts whole.
  • With an actor filter or split they read the daily totals, the only ones that carry actors. The interval is then whole days (UTC) and the first and last day count whole.
  • ai_cost is priced when it is read, with the prices as they are now, in the team's currency, as on the AI pages. Tokens without a price cost nothing. A call is paid by customer when its key (or the call) has an owner or the key says so, else by the project's default payer.
  • ai_tokens_input includes cached tokens and ai_tokens_output reasoning ones, so input plus output is every token once.
  • Only a team token where it may use get_ai_usage reads them. Any other token gets 403, public stats 422.

Prometheus ​

GET /metrics serves gauges for every project the credential reads, labeled with the project's slug. Counts and rates cover the last hour. The database gauges show each database check's latest report. The AI gauges cover the last complete hour (12:00 to 13:00 when scraped at 13:20), so a value does not grow while its hour fills up, and only show for a token that may use get_ai_usage. They have no key, owner or actor label: a project can have thousands of keys, and each would be a series of its own. Split by those in a series instead.

GaugeLabels
lumberjack_requestsproject
lumberjack_error_rateproject
lumberjack_request_duration_p95_secondsproject
lumberjack_apdexproject
lumberjack_open_issuesproject
lumberjack_users_affectedproject
lumberjack_failed_jobsproject
lumberjack_health_checksproject, state
lumberjack_queue_sizeproject, connection, queue
lumberjack_queue_workersproject, connection, queue
lumberjack_queue_oldest_age_secondsproject, connection, queue
lumberjack_agents_onlineproject
lumberjack_database_size_bytesproject, environment, check
lumberjack_database_connectionsproject, environment, check
lumberjack_database_max_connectionsproject, environment, check
lumberjack_ai_callsproject, environment, provider, model, status (ok, error)
lumberjack_ai_tokensproject, environment, provider, model, direction (input, output, cache_read, cache_write, reasoning)
lumberjack_ai_costproject, environment, provider, model, payer (us, customer), currency
yaml
scrape_configs:
    - job_name: lumberjack
      scheme: https
      metrics_path: /api/v1/metrics
      scrape_interval: 60s
      authorization:
          type: Bearer
          credentials: lj_mcp_...
      static_configs:
          - targets: ['your-lumberjack']

For public stats, drop authorization and set metrics_path to /api/v1/public/ps_.../metrics.

Grafana ​

  1. Install the Infinity data source and add one. Under Authentication, pick Bearer token, paste the token, and add your Lumberjack's address to Allowed hosts. For public stats, leave authentication off.

  2. In a panel, pick the data source, type JSON, source URL, format Time series, and a URL such as

    https://your-lumberjack/api/v1/projects/shop/series/p95?from=${__from}&to=${__to}&interval=${__interval}

    with Rows / root points and the columns t (timestamp), value (number) and series (string). With group_by each series becomes its own line.

  3. For a table, use format Table, a URL such as .../projects/shop/routes?period=24h, and Rows / root rows.

For AI cost per model, use a URL such as

https://your-lumberjack/api/v1/projects/shop/series/ai_cost?from=${__from}&to=${__to}&interval=${__interval}&group_by=model

and set the panel's unit to the currency the answer names. Add &payer=us for what your own keys cost.

In Prometheus, what customers' keys cost per model in the last complete hour is

promql
sum by (model) (lumberjack_ai_cost{project="shop", payer="customer"})

For alerting on gauges, use a Prometheus that scrapes /api/v1/metrics as above.

To start quickly, import docs/grafana/lumberjack.json under Dashboards, New, Import. It shows requests, error rate, p95 per route and the routes table for the project picked in the project variable.