Query App Logs
queryAppLogsRuns LogQL queries over an app's seven-day log history to return log lines or metric series for troubleshooting and monitoring.
Instructions
Runs a LogQL query over the app's own logs, kept for seven days, and returns Loki's answer unchanged: lines for a log query, series for a metric query. Streams: {container="<service>"} is each compose service's own output, with pod and a detected_level (error, critical, fatal, warn, info, debug, trace or unknown) to filter on as | detected_level=~"error|critical|fatal"; {container="_events"} holds the Kubernetes events about the app's objects as JSON (kind, name, reason, type, msg, count); {container="_access", service="<service>"} is the ingress access log of the service the app's address routes to, as Traefik's JSON (RequestMethod, RequestPath, DownstreamStatus, Duration in nanoseconds, request_User-Agent), with route, method and status as fields; and {container="_rum", kind="pageview"} with kinds vital, error, net, signal, custom and session holds browser monitoring, with page, session, device, browser, os and country as fields. Session recordings are kept apart: getBrowserSessionReplay reads them, with the developer role. A query the store refuses comes back with the store's own status and error. The path is the store's own, so a Grafana data source can point here too.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"workspaceSlug": "<workspaceSlug>",
"appSlug": "<appSlug>",
"query": "<query>"
},
"name": "queryAppLogs"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | End of the range; now when absent | |
| env | No | ||
| step | No | Seconds between points of a metric query, or a duration such as `1m` | |
| limit | No | Most lines to return for a log query, 100 when absent | |
| query | Yes | A LogQL query: a log query returns lines, a metric query such as `sum by (detected_level) (count_over_time({container="web"} [5m]))` returns series | |
| start | No | Start of the range, as Unix seconds, Unix nanoseconds or RFC 3339; an hour before `end` when absent | |
| region | No | ||
| appSlug | Yes | ||
| direction | No | `backward`, the default, returns the newest lines first | |
| workspaceSlug | Yes |