## 00 · what moblog keeps
Start here
moblog keeps the logs your apps write, on phones, in browsers and on servers, and helps you find the ones that explain a problem. This chapter is the vocabulary; the rest of the guide goes from your first event to an alert that tells you when something breaks.
Events
An event is one log line: a message, a level (trace, debug, info, warn, error or fatal), when it happened, and any attributes you add (cart.items=3, http.status_code=500). Events also carry who and where: the session, user and device, the app and its version, the platform, the OS and the environment.
- 09:42:48.215infocheckout: payment sheet opened provider=stripe
- 09:42:51.601errorcheckout: payment failed code=card_declined
Organizations, projects and keys
- An organization is your team: owners and members, who all see every project. Owners invite people with a link from Members.
- A project is one app (or one app per platform): its events, its retention (how many days they're kept), and its environments (
production,staging). - An ingest key (
mob_ingest_…) only sends events. It ships inside your app, so treat it as public. A secret key (mob_secret_…) reads and manages data: keep it on servers and in CI.
What moblog does with them
- Personal data is masked as events arrive, before anything is stored: emails, phone numbers, card numbers, tokens and IP addresses. You choose per project to mask, hash or keep each kind.
- Rules drop or sample noisy events (debug in production, most info events) before they're stored and counted.
- Messages are grouped into patterns, and error patterns become issues, without any setup.
- Every new app version is compared with the one it replaces, and monitors you set up alert you by email, Slack or webhook.
## 01 · keys, SDKs, HTTP
Send events
A new project opens on its quickstart: it creates an ingest key and fills it into snippets you can paste. The first event shows up there as soon as it arrives.
- 1 /Create a projectName it after the app. Pick how long its events are kept: 7 days on Free, 30 (up to 90) on Pro.
- 2 /Get an ingest keyThe quickstart makes one. For a web page, allow your sites on it, so other sites can't use it.
- 3 /Send an eventWith an SDK, over HTTP, with OpenTelemetry or from the terminal. The quickstart waits for the first one.
From web pages: @moblog/browser
About 3 KB, no dependencies. It batches events, retries them, keeps a session per tab, and sends page views and uncaught errors by itself.
import * as moblog from "@moblog/browser";
moblog.init({
key: "mob_ingest_...",
endpoint: "https://ingest.beta.moblog.dev", // during the beta
release: "2.4.1",
environment: "production",
});
moblog.info("checkout opened", { cart: { items: 3 } });
moblog.setUser("user-48213");
try {
await pay();
} catch (err) {
moblog.captureError(err, { provider: "stripe" });
}
// A request to your own API, followed to the server (its log.fromHeaders):
const t = moblog.trace();
moblog.info("order sent", { trace_id: t.traceId });
await fetch("/api/orders", { method: "POST", headers: t.headers, body });From servers and Next.js: @moblog/node
For Node 20+, edge runtimes, Bun and Deno. On Vercel it sends what was logged before a function freezes; it reports Next.js's server errors too.
import { createLogger } from "@moblog/node";
// The key from MOBLOG_INGEST_KEY; during the beta, MOBLOG_INGEST_URL=https://ingest.beta.moblog.dev
export const log = createLogger({ app: "shop-web" });
log.info("order paid", { order: { id: 812, total: 49.9 } });
// In a request handler: its events in the page's trace and session.
const req = log.fromHeaders(request.headers).child({ route: "/api/orders" });
req.warn("slow query", { "db.ms": 1840 });From apps, or anything else: HTTP
POST /v1/ingest takes one event, an array or a batch, as JSON, NDJSON or protobuf, compressed or not. Resending a batch with the same batch_id stores it once, so retrying after a lost connection is safe. OpenTelemetry exporters can send to /v1/logs instead.
curl https://ingest.beta.moblog.dev/v1/ingest \
-H "Authorization: Bearer mob_ingest_..." \
-H "Content-Type: application/json" \
-d '{"level":"error","message":"checkout: payment failed","user_id":"u-1842","attributes":{"code":"card_declined"}}'SDKs for Android (Kotlin), iOS (Swift) and React Native, with the offline queue built in, are on the way. Until then, apps send over HTTP. During the beta every example here sends to ingest.beta.moblog.dev, as the quickstart's snippets do.
Sending without making anyone wait
Ingest answers once your events are stored, not when they arrive. That takes around a tenth of a second, plus the network. Sent in the background, it costs your app nothing; awaited in a request handler or after a tap, every user waits for it.
- Send in batches, in the background. Queue events and send many per request from a timer (up to 10,000 events or 5 MiB). Never await a send where someone is waiting. The SDKs only queue when you log:
@moblog/browsersends every 5 seconds or at 100 events,@moblog/nodeevery 2 seconds or at 500. - Keep the connection. Make one client (or logger) per process, once. A new HTTPS connection costs about three round trips before the request goes out; a kept one costs none. The SDKs send with the runtime's
fetch, which keeps connections open, and the browser SDK opens its connection as the page starts. - Compress. Send
Content-Encoding: gziporzstd: the 5 MiB limit is on the compressed body (32 MiB once decompressed).@moblog/nodegzips bodies over 1 KB and the CLI sends zstd.@moblog/browsersends plain JSON: a batch under 60 KB goes withkeepalive, so it's still sent if the page closes meanwhile. - Send what's left when the user leaves.
@moblog/browserhands its queue tonavigator.sendBeaconwhen the page is hidden or closed: the browser sends it after the page is gone, and the page never learns whether it was stored. An app should send when it goes to the background (on iOS insidebeginBackgroundTask, on Android from WorkManager) and keep unsent batches on disk. On servers, see@moblog/node: on Vercel it's automatic, on Cloudflarectx.waitUntil(log.flush()), on AWS Lambda oneawait log.flush()before returning (the one send that waits).
What the answer means, and what to retry
- 200 means stored. The events counted in
acceptedare written before ingest answers.droppedcounts events a rule or a check removed, anderrorssays why: sending them again won't help. - Retry
408,429,5xxand network errors, afterRetry-Afterseconds when the answer has one, with the samebatch_id: the batch is stored once, however many times it arrives. Without abatch_id, a resent request is stored again. - Don't retry
400,401,403,413or415: the same request is refused again. Moblog-Quota: exceededon an answer means the organization has used its monthly quota: only errors are stored for a while, then every request gets429untilMoblog-Quota-Reset. The SDKs then send errors only.
Typical times
| what | time (median), and where it was measured |
|---|---|
| ingest's answer, light traffic | 100–115 ms, on a development laptop running the whole stack (no network). Nearly all of it is the database writing the batch. |
| ingest's answer, 5,000 events/s | 160–270 ms on the same laptop, about 100 events a request; less when the database groups writes for a shorter time. |
| ingest's answer, on AWS | 158 ms (272 ms p99) at 30,000 events/s, in a load test from the same region (October 2026). |
| the network, kept connection | 17 ms for a request to the beta's server (us-east-1) from a laptop on home internet. |
| the network, new connection | 67 ms for the same request: DNS, TCP and TLS first. |
Batching over plain HTTP
With curl, many events in one compressed request. --retry sends the same body again after a 429 or a 5xx, waiting Retry-After; the same batch_id keeps it from being stored twice.
export MOBLOG_INGEST_KEY=mob_ingest_... # an ingest key of this project
cat > batch.json <<EOF
{"batch_id":"$(uuidgen)","events":[
{"level":"info","message":"checkout opened","user_id":"u-1842"},
{"level":"error","message":"checkout: payment failed","user_id":"u-1842","attributes":{"code":"card_declined"}}
]}
EOF
gzip -kf batch.json
curl https://ingest.beta.moblog.dev/v1/ingest --retry 5 \
-H "Authorization: Bearer $MOBLOG_INGEST_KEY" \
-H "Content-Type: application/json" \
-H "Content-Encoding: gzip" \
--data-binary @batch.json.gzFrom code without an SDK: a queue, a timer and a retry that keeps the batch. Here in JavaScript; the shape is the same in Swift, Kotlin or anything else.
const INGEST_URL = "https://ingest.beta.moblog.dev/v1/ingest";
const KEY = process.env.MOBLOG_INGEST_KEY;
const queue = []; // events not in a batch yet
const batches = []; // oldest first; a batch keeps its batch_id until it is stored
let retryAt = 0;
let sending = Promise.resolve(); // one send at a time, in turn
// Only queues: never waits for ingest.
function log(level, message, attributes) {
queue.push({ timestamp: Date.now(), level, message, attributes });
}
// Resolves when what was queued is sent, or kept for a retry after Retry-After.
function flush() {
while (queue.length) batches.push({ batch_id: crypto.randomUUID(), events: queue.splice(0, 1000) });
// Ingest away for long: keep the oldest batch (it may be in flight) and the newest 10.
batches.splice(1, Math.max(batches.length - 11, 0));
sending = sending.then(send);
return sending;
}
async function send() {
while (batches.length && Date.now() >= retryAt) {
const res = await post(batches[0]).catch(() => undefined);
if (!res || res.status === 408 || res.status === 429 || res.status >= 500) {
// Not stored: send the same batch again later.
retryAt = Date.now() + (Number(res?.headers.get("Retry-After")) || 5) * 1000;
return;
}
batches.shift(); // 2xx: stored. Any other 4xx would be refused again.
}
}
async function post(batch) {
const gzip = new Blob([JSON.stringify(batch)]).stream().pipeThrough(new CompressionStream("gzip"));
return fetch(INGEST_URL, {
method: "POST",
headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json", "Content-Encoding": "gzip" },
body: await new Response(gzip).arrayBuffer(),
});
}
// In the background, every 2 s, over the connection fetch keeps open. Before the process exits,
// or the app goes to the background: await flush() (a batch waiting out a Retry-After stays unsent:
// keep it on disk if it must survive).
setInterval(flush, 2000);What to log
- What the user did and what the app decided: screens, taps that matter, requests and their outcome, retries.
- Numbers as numbers (
duration_ms=812), so you can chart them and alert on them. - Names that stay put:
http.route=/orders/:id, not the order's ID in the key. A project uses up to 1,000 attribute names in 30 days. - Never passwords or tokens. Masking catches the common ones, but it's a net, not a plan.
## 02 · the explorer, sessions
Find events
The explorer is a project's home: a query, a time range, the events over time and the events themselves. Most questions start here, and most answers end in one user's session.
The explorer
- Type a filter (
level:error app_version:2.4.*, more in the next chapter) and press Enter. Field names complete as you type, from the fields every event has and your project's own attributes. - Pick a range: 15 minutes to 7 days ending now, or fixed times. Drag across the chart to zoom in.
- Open an event for its times, context and attributes.
=and≠next to a value add it to the filter, or exclude it. - The query and range are in the URL: share the link, and the back button undoes a search.
- What's in common lists the values over-represented in the matching events' sessions: “92% Android 14, 80% Samsung”. Often the fastest way to a cause.
Sessions
A session is one run of the app, from launch (or the first page) to the last event. Sessions lists those with an event matching your filter, which makes it the user and device lookup too: user_id:u-48213.
- A session's timeline is every event in the order the app logged it, with the device, OS and app version above it.
- Batches that arrived late are marked: the device was offline, and the events kept the time they happened.
- Jump to the first error, narrow to warnings and errors, or move to the same device's previous and next session.
- Opened from an issue, a session marks the issue's events and lands on the first. Step through them, or to the older and newer session with the same issue.
Live tail
Live tail shows the events matching a filter as they arrive, a fraction of a second after the app sends them, already masked: what you'd find later with a search. Use it while you reproduce a bug on a test phone.
## 03 · filters and stages
The query language
One language everywhere: the explorer, live tail, the CLI, dashboards and monitors. A filter picks events; stages after a | count, group and sort them.
Filters
| write | matches |
|---|---|
timeout | the message contains the word, ignoring case |
"payment failed" | the message contains the phrase |
level:error | exactly that value |
app_version:2.4.* | * is a wildcard |
user_id:* | the field is set |
duration_ms:>500 | numbers: >, >=, <, <=, and 10..20 for a range |
level:>=warn | levels by severity: warn, error and fatal |
screen:(Cart OR Checkout) | any of the values |
-platform:ios | NOT: everything else |
a b, a OR b, ( ) | AND binds tighter than OR; keywords in capitals |
Fields every event has: level, message, user_id, session_id, device_id, app_version, platform, environment, os_version, device_model, page, country and more, some with short names (user, version, env). Any other name is one of your attributes: http.status_code, cart.items.
Stages
| stage | does |
|---|---|
| count() by app_version | a table: one row per group |
| p95(duration_ms) as p95 | count_distinct, sum, avg, min, max, p50, p90, p95, p99; as names a column |
| count() by bin(5m), level | over time: a chart with a line per group |
| top 10 screen | the most frequent values, with their counts |
| where cart.items:>3 | filters again |
| fields user_id, duration_ms | the columns of an event list |
| sort by p95 desc | limit 20 | order and size (up to 1,000 rows) |
level:error | count() as errors, count_distinct(user_id) as users by bin(5m), app_version
screen:Checkout | fields user_id, duration_ms | sort by duration_ms desc | limit 50
| top 10 app_version- With no filter, start with the
|:| count() by platformcounts every event. - To sort by an aggregation, name it:
| p95(duration_ms) as p95 by http.route | sort by p95 desc. - Don't group by IDs (
user_id,session_id): count them withcount_distinct(user_id). - A mistake is underlined where it is, with what's wrong.
## 04 · questions to queries
Ask in words
Don't know the query? Ask in words. A language model writes the query from your question and your project's field names, moblog checks it, and you run it.
How it works
- In the explorer, Ask opens a question box. The query lands in the query box, with a sentence on what it shows and what the model assumed. Check it, change it if you like, then run it over the range the question asked for.
- In the terminal:
moblog query --ask 'crashes on Android by device model this week'prints the query and the command that runs it;--runruns it. - The model sees your question and your project's attribute names, types and counts. Never your events.
- Nothing runs until you do, and a query that doesn't parse is sent back to the model once to fix.
Eight questions and their queries
- errors in the last hour by app
level:>=error | count() as errors by app_id | sort by errors descover the last hour - slowest API routes this week
duration_ms:* | p95(duration_ms) as p95, count() as requests by http.route | sort by p95 desc | limit 20over the last 7 days - how many 500s per hour today
http.status_code:500 | count() by bin(1h)over the last 24 hours, as a chart - how many distinct users yesterday
| count_distinct(user_id) as usersover the last 24 hours - crashes on iOS by device model
platform:ios AND level:fatal | count() as crashes by device_model | sort by crashes desc - events without a user
NOT user_id:* - the most common log messages
| top 10 patternpatterns: the next chapter - errors over time this month
level:>=error | count() by bin(1d)over the last 30 days, a point a day
These are real answers, on a project whose events carry an API's attributes (http.route, duration_ms, http.status_code). Your queries use your project's fields.
Asking well
- Name the time (“today”, “this week”): it becomes the range, not part of the query.
- Name what you'd group by (“by version”, “per route”) and how to rank (“slowest”, “most”).
- Use your attributes' words: if your events carry screen, say screen.
- The answer's sentence says what the model assumed. If it guessed wrong, edit the query or ask again.
Ask uses the organization's AI allowance: Pro includes one, Free doesn't. Each person can ask 20 questions a minute.
## 05 · patterns, issues, releases
What's going on
Some questions don't need a query: what does this app log, what broke, and did the last release make things worse? moblog works these out from your events as they arrive.
Patterns
A pattern is a kind of message, with the parts that change masked: added <*> to cart, GET /orders/<num>. Patterns lists them for any filter, most events first, each with its trend and a new mark when it appeared in the range. It's the quickest way to see what an app says, and what it started saying.
A pattern opens its events in the explorer (pattern:51d2c0a8e1f04b7c), and count() by pattern counts them in a query.
Issues
Every error or fatal pattern becomes an issue: what's broken, for how many users, since which version. Issues is the inbox: open, resolved or ignored; new or regressed; by users, events or newest.
- A new issue is emailed to the organization's owners about 10 minutes after it appears; choose other members, Slack or a webhook in the project's settings.
- Resolve one, optionally in a version (
resolved in 2.5.0): if it happens again in that version or a later one, it reopens as regressed, and you're told at once. - An issue's page lists what its sessions have in common, and the versions it appears in.
- Its latest sessions are on its page too, each opening at the issue's first event. The Sessions card opens all of them, and each version links to its own.
- Explain on an issue's page asks a language model for its likely cause, from the facts moblog computed (its versions, what its sessions have in common, the steps they logged before it), never your events. Each cause links to the facts it rests on; asking again within the hour costs nothing.
Releases
Releases answers “did 2.4.1 make things worse than 2.4.0?”: sessions, users, crash-free sessions, and errors and fatals per 1,000 sessions, side by side, then the messages that are new or growing in the newer version. Rates per 1,000 sessions keep versions with different adoption comparable.
- Release health does it for you: every new version is checked against the one it replaces, every hour for a week, without any setup.
- A version is worse when crash-free sessions drop by a point, errors per 1,000 sessions grow by half, or a new issue reaches 3 sessions. You're told once, with the reasons.
- Narrow to a platform: versions mean different builds on iOS and Android.
- Explain under a comparison asks a language model why the newer version may do worse, from the comparison's facts (both versions' rates, release health's verdict, the new or growing messages, what its sessions with errors have in common), as an issue's.
moblog releases compare 2.4.1 --fail-if crash-free<99.5 --fail-if errors-per-1k>+20%## 06 · alerts, and describing them
Monitors
A monitor runs a query every minute and tells you when its value crosses a line, or leaves what's usual, and again when it's back. Write one yourself, start from a query in the explorer, or describe it in a sentence.
What a monitor is
| part | what it is |
|---|---|
| query | An aggregation without bin(), sort or limit: level:error | count(). With by app_version, each version is watched on its own. |
| window | How many minutes of events each check counts: 5 minutes to a day, ending 2 minutes ago so late events arrive first. |
| condition | Above or below a threshold, or unusual (below). |
| channels | Members by email; on Pro, also the organization's Slack and webhook channels. |
| while alerting | Only when the state changes, or again every so often until it's over. |
- Create monitor in the explorer starts one from the query that ran.
- A monitor's page charts its value against the line, shaded where it alerted, and lists its groups now.
- Mute one while you work on the problem: it keeps checking but tells no one, for up to 90 days.
- When an alert starts, the message also says what the window's events have in common.
- Explain on an alerting monitor's page asks a language model why it alerts, from the facts moblog computed about the alert (its groups against their usual values, the versions first seen around its start, the messages that grew, what its events' sessions share), as an issue's.
Unusual: no threshold to guess
An unusual monitor compares the value with what its own history expects at that time: the same window on the last 7 days and on the same weekday 2 to 4 weeks back. Monday mornings are judged against Monday mornings. Pick which way to alert (higher, lower or either) and how sensitive. The threshold becomes a floor: with 5, two errors instead of one at 3 a.m. wake no one. A new monitor learns from the events you already have; a group with less than 4 days of history waits before it alerts.
Describe it
In the new monitor dialog, write what you want to hear about and press Draft. The model fills in the form: query, condition, threshold, window and who to tell, with a sentence on what it assumed. Check it, change anything, and create it. Nothing is created until you do.
- email me when there are more than 10 server errors in 5 minutes
level:>=error | count()above 10, over 5 minutes → you - tell #oncall if p95 latency goes above 1 second
duration_ms:* | p95(duration_ms)above 1000 (ms), over 15 minutes → #oncallSeconds became the field's unit; the window, which the description didn't name, is 15 minutes. - alert me if errors spike
level:>=error | count()unusually high, over 15 minutes (from 5) → you“Spike” has no number: it's compared with what's usual at that time. - let me know if we stop getting requests
duration_ms:* | count()below 1, over 30 minutes → you - crashes on iOS, remind me every 30 minutes
level:fatal AND platform:ios | count()above 0, over 15 minutes, again every 30 minutes → you - notify ops@example.com when 404s double
http.status_code:404 | count()unusually high, over 15 minutes (from 10) → ops@example.comAn address in the description is kept when it's a member's; others are dropped. - error rate above 5%
level:>=error | count()unusually high, over 15 minutes (from 10) → youA monitor watches one value, not a ratio: the explanation says so, and watches the errors instead. - no events from android for an hour
platform:android | count()below 1, over 60 minutes → you
These are real drafts, on a project whose events carry an API's attributes, with a Slack channel named #oncall. The model sees your description, your project's attribute names and counts and your channels' names: never your events, nor your members' addresses.
Describing well
- Say how much and how fast: “more than 20 in 5 minutes” is a threshold and a window.
- Say it relatively when you can't put a number on it: “spikes”, “drops”, “more than usual” become an unusual monitor.
- Say “stops” or “no events” to hear when something goes quiet.
- Name who to tell:
meis you, a channel by its name, or a member's address. With none, it emails you. - Say “per version” or “per route” to watch each one on its own.
- Add “remind me every hour” to hear again while it lasts.
In the terminal: moblog monitors draft 'email me when checkout errors pass 20 in 5 minutes' shows the draft and asks before creating it; --save creates it without asking. Drafting uses the organization's AI allowance, like Ask.
## 07 · views and the weekly email
Dashboards and the digest
A dashboard keeps the queries you look at every day on one screen. The weekly digest brings the week's numbers to your inbox, so you notice what changed without opening anything.
Dashboards
- Add to dashboard in the explorer puts the query that ran on a dashboard, with the chart that suits it.
- Charts: a line over time (
by bin(5m)), bars and a top list (bya field), a number (no groups), and a table. - A dashboard has one time range, environment and app version for all its widgets, in the URL to share; a range ending now refreshes every 30 seconds.
- Free organizations have 3 dashboards; Pro, as many as they like.
The weekly digest
Each project's week against the week before: sessions, crash-free sessions and errors per 1,000 sessions, the new issues and regressions, the releases checked, the messages that grew most, and the monitors that fired. Owners get it by default, on Monday at 09:00 UTC. Each member picks the day, the hour, the time zone, and one email for the organization or one per project, in the organization's settings.
## 08 · the CLI and AI tools
The terminal
What the web app does, the moblog CLI does too, and its output pipes into the tools you already use: a table on a terminal, JSON when piped.
moblog login
Logged in to Acme (acme) as ana@acme.dev, on this computer as "ana-mbp".
moblog projects use shop
moblog tail 'level:error'
09:42:51 ERROR checkout: payment failed code=card_declined user_id=1842
moblog query 'level:error | count() by app_version' --since 7d
APP_VERSION COUNT() 2.4.1 1204 2.4.0 311
Installing
The CLI will install with Homebrew or npm, on macOS, Linux and Windows. The packages aren't published yet; this part will have the commands when they are.
Logging in
moblog login opens the web app, where you check the code and approve it: the CLI then acts as you, in the organization you picked. In CI, use a secret key instead: MOBLOG_API_KEY=mob_secret_….
AI tools: moblog mcp
moblog mcp lets AI tools like Claude Code and Cursor read your logs: queries, sessions, issues, patterns, releases and monitors, read-only, with your login. The model is your tool's, so moblog's AI allowance isn't used.
claude mcp add moblog -- moblog mcpmoblog setup writes a skill for coding agents: how to add moblog to an app, which keys go where, what never to log, and how to read the logs with the CLI.
## 09 · syntax and commands
Cheat sheet
The syntax and the commands, on one page.
Queries
level:>=error app_version:2.4.* -platform:ios "payment failed"
duration_ms:>500 (screen:Checkout OR screen:Cart) user_id:*
level:error | count() by app_version
| count() by bin(1h), level
| p95(duration_ms) as p95 by http.route | sort by p95 desc | limit 20
| count_distinct(user_id) as users
| top 10 pattern
screen:Checkout | fields user_id, duration_ms | sort by duration_ms descCommands
| command | does |
|---|---|
moblog query '…' --since 24h | search, or a table for an aggregation; -o json|csv |
moblog query --ask '…' | a question in words becomes a query; --run runs it |
moblog tail '…' | events as they arrive, until Ctrl-C |
moblog sessions 'user_id:u-1' | the sessions with a matching event |
moblog session <id> | one session, in the order the app logged it |
moblog patterns 'level:>=warn' | the kinds of messages, most events first |
moblog common '…' | what the matching events' sessions have in common |
moblog issues | errors seen in the last 7 days; resolve, ignore, reopen |
moblog issues explain <id> | an issue's likely cause, with the facts behind it |
moblog releases compare 2.4.1 | a version against the one before it; --fail-if for CI |
moblog releases explain 2.4.1 | why it may do worse, with the facts behind it |
moblog monitors | monitors and their state; mute, unmute |
moblog monitors draft '…' | a monitor from a description; --save |
moblog monitors explain <id> | why an alerting monitor alerts, with the facts behind it |
moblog ingest file.ndjson | send events from files or stdin; --text for plain lines |
moblog keys, envs, settings | keys, environments, masking and ingest rules |
moblog digest preview | the weekly digest as it would be sent now |