Query logs in plain English

Ask Claude Code a question about your logs; it writes a read-only query, runs it, and shows the query, the results and what stands out.

Task: Query logs in plain English · Other tasks

Fill in the details

Optional. The table, index or tool Claude should query. Without it, Claude looks at the schema first.

Copy your prompt

This site doesn't run Claude or show model output. Results depend on your input and the model you use.

3 required fields are empty.

What you type is kept in this tab's session storage so a reload doesn't lose it. Use "Clear this task" to remove it. Browsers can restore session data when they reopen tabs, so closing a tab isn't a guaranteed way to erase it.

When to use this template

  • You have a question about what happened in a system, such as failed logins or error spikes, and you would rather describe it than write the query yourself.
  • Claude Code can already reach the logs: through an MCP server connected to the log database, ideally with a read-only database user, or through a command line tool for your logging platform that is installed and signed in.
  • You want to see the query next to the answer, so you can check what actually ran before you trust the numbers.

When not to use it

  • Claude Code has no connection to the logs. Connect the database or logging tool first, for example with the MCP template, or export the relevant lines and paste them into an incident investigation instead.
  • The logs hold personal or regulated data that your policy does not allow an AI tool to read. Use an approved tool, or a redacted copy.
  • You need a dashboard or an alert that runs every day. Use this prompt to work out the query, then put it in your monitoring system.

Why this structure

  • The three required fields say what to find, where, and over which window, which is what a log query needs before it can be written at all.
  • Read-only queries keep the work to reading. The time filter narrows the window and the row limit caps the rows returned, but neither caps how much data a query scans, so the prompt also asks Claude to check a query plan, scan estimate or budget before an expensive query.
  • Asking Claude to check the schema and say which table or field it picked lets you spot a guessed name before an empty result gets read as "nothing happened".
  • Log records can contain text an attacker typed, such as user names or request paths, so the rules tell Claude to treat those values as data.
  • The report starts with the exact queries, so you can rerun or correct them, and ends with what could not be queried, so a gap shows up as a gap rather than as a clean result.

Example input (fictional)

What to look for
password reset requests
Which system or service
the accounts API
Time range
the last 7 days
Where the logs live
the api_requests table, through the warehouse MCP server

Follow-ups to send Claude

  • Break the results down by hour and show the five busiest hours next to the same hours yesterday.
  • For the top three source addresses, show every other event they produced in the same window.
  • Turn the query into a saved file in this repository with a comment explaining what it measures.

Common mistakes

  • Connecting the database with a user that can write. Use a read-only user, so a wrong query cannot change data even if the rule is missed.
  • Leaving the time range vague, such as "recently". The query then either misses events or scans far more data than needed.
  • Trusting a count without reading the query. A wrong filter or join can make the numbers look normal when they are not.

See all templates

Sources