Skip to content

When something breaks

Follow a request

Follow one request from the browser to the database, and see where the time went.

Open Traces in the dashboard, or in a terminal:

Terminal window
kiyesi traces
kiyesi traces --all --since 1h --search /api/orders
kiyesi trace req_2b77f0d3

Slow or failed lists requests that took a second or more, or failed with a server error (a status from 500 to 599). Linked to an incident lists the slow or failed ones that happened during a recent incident, on the servers and frontends it involved. All requests lists the rest too. Paste a request ID to find one anywhere in the 7 days kept, or type an address such as /api/orders. In Logs, open any line with a request ID and choose Follow this request.

Step How it is known What it needs
Browser Measured by the browser snippet The snippet
Web server Measured from its access log, which records the request ID and the time Caddy: nothing. nginx: two fields, below
Backend app Measured from your app’s own lines that carry the request ID One line in the app that logs the ID
Database Matched by time against the slow-query log, so it is likely and not certain The slow-query log turned on
Inside the app Worked out: the time left once the measured steps are taken away Nothing

A database line that carries the request ID itself is measured, not matched. A slow query is matched only when it ran during the request, on the same server or another server of the same project and environment.

This is not code-level tracing: Kiyesi does not show which function inside your app was slow.

Caddy needs nothing: its JSON access log records each request’s headers, the answer’s headers and the time. Turn the log on as in See what a server looked like.

nginx: in the http block, add how long the request took and its ID to the end of your log format:

log_format kiyesi '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent" $request_time $request_id_out';
map $http_x_request_id $request_id_out {
default $http_x_request_id;
"" $request_id;
}
access_log /var/log/nginx/access.log kiyesi;

and in each location that passes requests to your app:

proxy_set_header X-Request-Id $request_id_out;

Then reload nginx. This keeps the browser’s ID, makes one when there is none, and passes it to your app.

Log the X-Request-Id header with each request, as a field such as reqId, requestId, request_id or trace_id in JSON lines, or as request_id=… in plain text. One line at the end of each request, with its answer and time, gives the backend step its time.

// Express, with pino-http: one JSON line per request, with its ID.
import { randomUUID } from "node:crypto";
import express from "express";
import { pinoHttp } from "pino-http";
const app = express();
app.use(pinoHttp({ genReqId: (req) => req.headers["x-request-id"] ?? randomUUID() }));
app.get("/hello", (_req, res) => res.send("hello"));
app.listen(8080);

Each of these runs, in its stack’s own official image, for every change: a request with an X-Request-Id goes in, and Kiyesi’s own log reader must find that ID in the app’s line. Fastify needs only genReqId: (req) => req.headers["x-request-id"] ?? randomUUID() with its logger on. In Spring Boot, put the header in a OncePerRequestFilter as the Java tab does, and in Laravel or Symfony the PHP lines go at the top of public/index.php. Without the line’s own time, Kiyesi takes the time from your app’s first line for the request to its last.

Turn on the slow-query log, and send it where the agent reads it (the database container’s output, or the system log):

  • PostgreSQL: log_min_duration_statement = 200 (milliseconds), then reload.
  • MySQL and MariaDB: slow_query_log = 1 and long_query_time = 0.2; in a container, also slow_query_log_file = /dev/stderr, so the lines reach its output.
  • MongoDB: on by default for queries over 100 ms; change it with db.setProfilingLevel(0, { slowms: 200 }).

Kiyesi keeps only the time and the table from these lines, never the query’s values.

Add the browser snippet. It adds an ID to your site’s own requests, and for each one that took a second or more, or failed, it sends how long the browser waited. To change that one second, set data-slow-ms, in milliseconds, such as data-slow-ms="500". If your API is on another address, list it in data-trace-origins, after allowing the X-Request-Id header there. If your API already returns an X-Request-Id header that pages may read (Access-Control-Expose-Headers: X-Request-Id), the snippet uses that ID instead and adds nothing.

Each trace opens with one sentence, such as 85% of this request was spent inside the backend, outside its database queries. When the web server answered 502 or 504 (it could not reach your app, or your app took too long) and the backend has no line for the request, it says the request stopped at the web server. In the list, the Where the time went column is left out when every request in it spent all its time in one place, as when only the backend’s lines carry the request ID.

Anyone whose role has View on traces and who can see the servers or frontends involved: Owner, Admin, Member and Viewer, and any role you made with it, only within their projects, and not for servers their role leaves out. Billing and Client do not see traces.

  • Traces are kept 7 days, as log lines are.
  • A list shows at most 50 requests; search for an address or ID to narrow it.
  • No requests appear. Check that your web server’s log carries the request ID: Caddy’s JSON access log, or nginx’s format above.
  • No backend step. Your app’s lines do not carry the ID. See Your app.
  • No database step. The slow-query log is off, or no query took long enough to be logged.
  • Only the browser saw it. The request reached no server that logs the ID, or the server is not connected.