Skip to Content
Xeonr Developer Docs

Reading

Query a client project's logs and events and tail them live with a read token, over Lantern's ClientReadService. The token's grant decides what any call can see.

A token with a read grant reads its own project's records back from lantern.api.v1.ClientReadService, served on the ingest host, https://in.lntrn.dev. It is how you show your customers their own devices' logs — an admin's log pane, a support tool, a device's session history — without putting them in your console or your API in the read path.

The token is the whole authorization. It goes in the Authorization header of every call, the project is always the one its key belongs to, and the grant's filters are applied to every query, facet, timeline and tail — a request can narrow what it reads and can never widen it. Mint the token on your backend as described in Authentication; hand only the token to the browser or app that reads.

RPCReturns
ListClientLogsA page of log records, newest first
ListClientEventsA page of events, newest first
GetClientFacetsThe most frequent values of some keys
GetClientTimelineRecord counts over time, optionally split by one key
TailClientRecordsRecords as they arrive, as a stream

The client

@lntrn/web/read speaks all of it, with no dependencies and no protobuf runtime:

npm install @lntrn/web
import { createReader } from "@lntrn/web/read";

const reader = createReader({
  url: "https://in.lntrn.dev",            // the default
  token: () => api.mintTelemetryReadToken(), // a string, or a function returning a current one
});

// History, newest first, cursor-paged.
const { records, nextCursor } = await reader.listLogs(
  { minSeverity: "warn", filters: [{ key: "attr:session_id", values: [sessionId] }] },
  { limit: 200 },
);
const older = await reader.listLogs({ minSeverity: "warn" }, { cursor: nextCursor });

// Events, facets and a timeline.
await reader.listEvents({ from });
await reader.facets("logs", ["severity", "service.instance.id"], { from });
await reader.timeline("logs", { from }, "severity");

// Live.
const tail = reader.tail({
  kinds: ["logs"],
  minSeverity: "error",
  onRecords: (records) => append(records),
  onStatus: (status, detail) => show(status, detail),
});
tail.close();

A token function is called for every request and every reconnect, so cache in it and re-mint shortly before expiry; a tail outlives any one token. A refused call throws a ReadError whose code is the Connect code and whose refused is true when retrying cannot help.

The history calls are plain fetch POSTs, so they work in React Native as well as a browser. The tail needs a streaming response body, which React Native's fetch does not have: poll listLogs there.

Selecting records

Every history call takes a selection:

Field
fromInclusive start. Unset reads as far back as retention and the token's maxAgeSeconds allow.
toExclusive end. Unset is now.
filtersUp to 32, ANDed with each other and with the token's grant.
minSeveritytrace, debug, info, warn, error or fatal: that severity and above. Logs only.

Filters

A filter is a key, an operator and values:

{ "key": "attr:session_id", "op": "eq", "values": ["s-9"] }
KeyMatches
service.instance.idThe device, install or browser tab — the sub of the token that wrote it
service.versionThe release that sent it
severitytrace, debug, info, warn, error, fatal
bodyThe log message
event.nameAn event's name
trace_id, span_idTrace context
attr:<key>One of the record's own attributes, e.g. attr:session_id

Any other key is refused with invalid_argument, so the identity Lantern stamps on a record cannot be filtered on from a client.

Operators are eq, neq, in, not_in, contains, not_contains, exists, not_exists, gt, gte, lt, lte, regex and starts_with. exists and not_exists take no values; in and not_in take one or more; the rest take one. With the client, op defaults to eq for one value and in for several.

Severity is ordered, so { "key": "severity", "op": "gte", "values": ["warn"] } is warn, error and fatal — the same as minSeverity: "warn". The text operators (contains, not_contains, regex, starts_with) do not apply to it.

These keys are not quite the ones a token's grant is written in — a grant says client_id where a request says service.instance.id. The mapping is in Authentication.

Pages

ListClientLogs and ListClientEvents return records newest first, 100 per page unless you ask for up to 500. Pass a page's nextCursor back as cursor for the next one; it is empty on the last page.

A log record:

{
  "id": "16112394882102834",
  "timestamp": "2026-10-16T12:00:00Z",
  "instanceId": "device-4711",
  "severity": "error",
  "body": "upload failed",
  "traceId": "",
  "spanId": "",
  "attributes": { "session_id": "s-9" },
  "release": "1.4.2"
}

An event has id, timestamp, instanceId, name, value (when it carried one), attributes and release. severity is empty for a record that had none.

Facets and timelines

GetClientFacets counts the most frequent values of up to 20 keys over a selection — 10 values per key unless you ask for up to 100. GetClientTimeline counts records per time bucket over a selection that must name from, optionally split into one series per value of a key ("severity", say). The server chooses the bucket width for the range and returns it as step; buckets with no records are omitted. Both take a kind, logs or events, and accept the same keys as filters.

Live tail

TailClientRecords is a server stream on the same bearer token — there is no ticket to exchange and nothing in the URL. It takes kinds (logs, events, or both; empty is everything the grant allows), filters and minSeverity, and sends batches of records, oldest first within each batch, a few seconds after they land.

Things to know when you hold one open:

  • The stream opens with an empty message, and sends another every 20 seconds to keep intermediaries from closing an idle connection. An empty message is a keepalive, not an end.
  • A stream ends after 30 minutes. Reconnect with a fresh token: the token's authority is checked again on every stream, and a revoked key ends an open stream with unauthenticated.
  • A tail does not replay. Records that land while you are reconnecting are not sent on the next stream; read history for the gap.
  • minSeverity narrows logs only. Combined with events in kinds the tail is refused, because events have no severity.
  • A refusal is a verdict. unauthenticated, permission_denied or invalid_argument will not change on retry; anything else is worth a backoff.

The client's tail() does all of this. Its statuses are connecting, live, reconnecting (the detail says why), refused (a verdict — the tail has stopped) and closed.

On the wire

It is the Connect protocol, so any Connect or gRPC client generated from the service works, and so does plain HTTP. A history call is a JSON POST:

POST https://in.lntrn.dev/lantern.api.v1.ClientReadService/ListClientLogs
Authorization: Bearer <token>
Content-Type: application/json
Connect-Protocol-Version: 1

{
  "selection": {
    "from": "2026-10-16T00:00:00Z",
    "filters": [{ "key": "attr:session_id", "op": "FILTER_OP_EQ", "values": ["s-9"] }],
    "minSeverity": "warn"
  },
  "limit": 200
}

Over JSON, operators are spelled as their enum names (FILTER_OP_EQ, FILTER_OP_STARTS_WITH, …) and kinds as CLIENT_RECORD_KIND_LOGS and CLIENT_RECORD_KIND_EVENTS. The tail is the same path with Content-Type: application/connect+json and an enveloped request body.

From another origin

The ingest answers CORS preflights from any origin and never uses cookies, so a page you host can call it directly with a read token. A browser has nothing of ours to attach to your requests: your page acts with the token you gave it and nothing else.

Errors

Connect codeMeaning
unauthenticatedNo token, or one that is malformed, unknown, expired, outlives its key's maximum lifetime, or whose key was revoked
permission_deniedA valid token whose grant does not cover the call — no read grant, a kind its primitives leave out, or a grant its key may not mint
invalid_argumentThe request cannot be evaluated — an unknown filter key, an operator that does not apply, limit over 500, a malformed cursor, a timeline without from; the message names what
deadline_exceededThe query took too long; narrow the window or the filters
resource_exhaustedToo many tails are open for the project; retry later
unavailableLantern could not answer; retry

See Authentication for the exact token messages.

Moving from forest's read API

Before Lantern, reads went through forest's xeonr.forest.v1.QueryService and a live tail that exchanged the token for a ticket at /live/ticket and streamed Server-Sent Events from /live/stream. Those are gone; use ClientReadService. Tokens and grants do not change. What does:

  • No project id, no ticket. The project is the token's, and the tail takes the token as a bearer like every other call.
  • Filter keys. client_id → service.instance.id, level → severity (or minSeverity), message → body, name → event.name; attr:<key> is unchanged. Operators are the list above.
  • @xeonr/forest/live is gone. openLiveTail(…) becomes createReader({ token }).tail(…) from @lntrn/web/read.
  • Logs and events only. Metrics cannot be read or tailed here.

On this page