Official agent skill

Logfire Query

by pydantic in pydantic/skills

Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results.

OfficialMITAuto-check passedDatabases

Install Logfire Query

skills CLI
$ npx skills add pydantic/skills --skill logfire-query -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install pydantic/skills logfire-query --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/pydantic/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/logfire-query .claude/skills/logfire-query && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
logfire-query
GitHub stars
140
Token cost
~2.2k tokens
SKILL.md length
848 words
Files
3 (incl. references)
Skills in repo
9
Repo updated
First seen
Licence
MIT

At a glance

Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results.

  • Works in 6 steps: Always LIMIT — start with 20, increase… → Use min_timestamp/max_timestamp params… → Filter efficiently — service_name,… → …
  • The user asks to query logfire
  • SKILL.md covers When to Use This Skill, User-Facing Progress, Critical Routing: One Workflow… and Two Approaches, plus 6 more sections
  • Reaches logfire-api.pydantic.dev and logfire-us.pydantic.dev

What it does

Logfire Query is an agent skill from pydantic/skills, published by the product's own GitHub organization. Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results. Use this skill when the user asks to "query logfire", "search traces", "find logs", "query data", "search spans", "look up errors in logfire", "get metrics from logfire", "analyze telemetry", "summarize errors", "find root cause", or add Logfire querying capabilities to code. Do not use this skill for direct Logfire UI, browser, live-view, Explore-page, or link-opening requests; use logfire-ui instead. If "show"…

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/client-usage.md` and `references/schema.md`).

It sits in Databases, covering Root cause analysis and SQL. It works with SQL and Model Context Protocol. The licence is MIT.

When your agent uses it

  • The user asks to query logfire
  • Look up errors in logfire
  • Get metrics from logfire
  • Analyze telemetry

Example prompts

  • “query logfire”
  • “search traces”
  • “find logs”
  • “/logfire-query”

Requirements

  • Python 3

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Always LIMIT — start with 20, increase as needed
  2. Use min_timestamp/max_timestamp params for simple time windows instead of SQL WHERE
  3. Filter efficiently — service_name, span_name, trace_id, is_exception are fast filters
  4. Use ->>'key' for JSON attribute access (returns text); use -> for nested JSON objects
  5. Avoid SELECT * — select only the columns you need
  6. Max 14-day range — queries cannot span more than 14 days

What it can do on your machine

Read from SKILL.md and the folder at commit 238d971. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • logfire-api.pydantic.dev
    • logfire-us.pydantic.dev
    • logfire-eu.pydantic.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Logfire Query loads about 2.2k tokens when it runs, and up to ~5.7k if it reads all its reference files. Until then it costs about 155 tokens; SKILL.md has 848 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~155
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~5.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from pydantic/skills at commit 238d971, republished under its MIT licence (© pydantic). 848 words, ~2,248 tokens.

Download SKILL.mdSave it as .claude/skills/logfire-query/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
logfire-query
description
Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results. Use this skill when the user asks to "query logfire", "search traces", "find logs", "query data", "search spans", "look up errors in logfire", "get metrics from logfire", "analyze telemetry", "summarize errors", "find root cause", or add Logfire querying capabilities to code. Do not use this skill for direct Logfire UI, browser, live-view, Explore-page, or link-opening requests; use logfire-ui instead. If "show" or "view" wording is ambiguous, ask whether the user wants a UI view or query analysis.

Query Logfire Data

When to Use This Skill

Invoke this skill when:

  • User wants to query traces, logs, spans, or metrics from Logfire
  • User wants to search for specific events, errors, or patterns in telemetry data
  • User wants to analyze OpenTelemetry data stored in Logfire
  • User wants to add programmatic query capabilities to their code
  • User asks to "query logfire", "search traces", "find logs", "get metrics", "count", "summarize", "compare", or "find root cause"

User-Facing Progress

Keep progress updates terse. Do not narrate route classification, local skill instructions, schema selection, or routine query setup. If an update is needed, use one short sentence focused on the action, such as "Querying recent Logfire errors."

Critical Routing: One Workflow Per Request

Before using any query tool, classify the request.

  • Query route: "analyze", "query", "count", "summarize", "compare", "find root cause", "find slowest", "look up errors", "get metrics", or "add query capabilities".
  • UI route: "open", "show in browser", "show in Codex", "show in Logfire", "live view", "open Explore", "open the UI", "give me a link", or GUI/browser presentation. Use logfire-ui; do not call query_run just to make a URL.
  • Ambiguous route: prompts like "show recent errors", "view logs", or "show spans" do not specify whether the user wants chat analysis or the Logfire UI. Ask the user to choose query analysis or UI view.
  • Combined route: if the user explicitly asks for both analysis and a link, query only for the requested analysis or to identify the requested item, then provide the relevant Logfire link. Do not add UI/browser work unless the user asked for it.

Only query before opening Logfire UI when the user asks to open a specific unknown item that must be found first, such as "find the slowest trace and open it" or "open the latest error trace".

Two Approaches

AspectMCP query_runREST API /v1/query
Best forInteractive analysis in CodexAdding query code to a project
AuthOAuth via MCP sessionBearer read token
SetupAlready configured via pluginNeed a read token
FormatsJSON rowsJSON, CSV, Apache Arrow
Default windowLast 30 minLast 24 hours
Max range14 days14 days
Row limitMust be in SQLDefault 500, max 10,000

Quick Schema Reference

records table (spans and logs)

Key columns for querying:

ColumnTypeDescription
start_timestamptimestamp (UTC)When span/log was created
end_timestamptimestamp (UTC)When span/log completed
durationdouble (seconds)Time between start and end; NULL for logs
trace_idstring (32 hex)Unique trace identifier
span_idstring (16 hex)Unique span identifier
parent_span_idstring (16 hex)Parent span; NULL for root spans
span_namestringLow-cardinality label for similar records
messagestringHuman-readable description with arguments filled in
levelintegerSeverity (supports level = 'error' string comparison)
kindstringspan, log, span_event, or pending_span
service_namestringService identifier
is_exceptionbooleanWhether an exception was recorded
exception_typestringException class name
exception_messagestringException message
exception_stacktracestringFull traceback
attributesJSONStructured data; query with ->>'key'
tagsstring[]Grouping labels; query with array_has(tags, 'x')
http_response_status_codeintegerHTTP status code
http_methodstringHTTP method
http_routestringHTTP route pattern
otel_status_codestringSpan status
Show full SKILL.md (333 more words)Show less
metrics table
ColumnTypeDescription
recorded_timestamptimestamp (UTC)When metric was recorded
metric_namestringMetric name
metric_typestringType (gauge, counter, histogram)
unitstringUnit of measurement
scalar_valuedoubleMetric value
service_namestringService identifier
attributesJSONMetric dimensions

Full schema: references/schema.md

SQL Syntax

Logfire uses Apache DataFusion (Postgres-like). Key patterns:

sql
-- Time filtering
WHERE start_timestamp > now() - interval '1 hour'

-- JSON attribute access
WHERE attributes->>'user_id' = '123'
SELECT attributes->>'http.url' as url FROM records

-- Nested JSON
attributes->'request'->>'method'

-- Array filtering
WHERE array_has(tags, 'production')

-- Level filtering (string comparison works)
WHERE level = 'error'

-- Case-insensitive matching
WHERE message ILIKE '%timeout%'

-- Time bucketing for aggregation
SELECT time_bucket(interval '5 minutes', start_timestamp) as bucket,
       count(*) FROM records GROUP BY bucket ORDER BY bucket

MCP Approach (Interactive)

Call the query_run MCP tool:

  • query (required): SQL query string
  • project (optional): target project (default: user's current project)
  • min_timestamp / max_timestamp (optional): ISO timestamps for time window

Default window is last 30 min. Max range is 14 days. Always include LIMIT in SQL.

Common queries
sql
-- Recent errors
SELECT start_timestamp, message, exception_type, exception_message
FROM records WHERE is_exception LIMIT 20

-- Slow spans
SELECT span_name, duration, start_timestamp
FROM records WHERE duration > 1.0 ORDER BY duration DESC LIMIT 20

-- Endpoint errors
SELECT start_timestamp, message, http_response_status_code
FROM records WHERE http_route = '/api/users' AND level = 'error' LIMIT 20

-- Full trace
SELECT span_name, message, duration, parent_span_id
FROM records WHERE trace_id = '<id>' ORDER BY start_timestamp

-- Error breakdown by service
SELECT service_name, count(*) as errors
FROM records WHERE is_exception GROUP BY service_name ORDER BY errors DESC

If the user explicitly asks for both analysis and a Logfire link, finish the query analysis first, then use a Logfire link only for the known result:

  • For a known trace_id, use project_logfire_link(trace_id=trace_id, project=project, handoff=True) only when the user asked to open it immediately in the browser. Use project_logfire_link(trace_id=trace_id, project=project) for a durable or shareable URL.
  • For a project/filter view, use the logfire-ui routing rules.
  • Do not open the browser unless the user asked to open the link.

For a span-count prompt, provide SQL like this when the user wants an aggregate query or analysis:

sql
SELECT
  time_bucket(interval '5 minutes', start_timestamp) AS bucket,
  count(*) AS span_count
FROM records
WHERE kind = 'span'
GROUP BY bucket
ORDER BY bucket
LIMIT 200

REST API Approach (Programmatic)

Endpoint: GET https://logfire-api.pydantic.dev/v1/query

Region variants:

  • US: https://logfire-us.pydantic.dev/v1/query
  • EU: https://logfire-eu.pydantic.dev/v1/query

Auth: Authorization: Bearer <read_token>

Parameters:

  • sql (required): SQL query
  • min_timestamp / max_timestamp (optional): ISO timestamps
  • limit (optional): row limit (default 500, max 10,000)

Response formats (via Accept header):

  • application/json — column-oriented JSON (default)
  • application/json with row_oriented=true param — row-oriented JSON
  • text/csv — CSV
  • application/vnd.apache.arrow.stream — Apache Arrow

Python clients: LogfireQueryClient (sync), AsyncLogfireQueryClient (async), logfire.db_api (PEP 249 / pandas).

Detailed examples: references/client-usage.md

Query Best Practices

  1. Always LIMIT — start with 20, increase as needed
  2. Use min_timestamp/max_timestamp params for simple time windows instead of SQL WHERE
  3. Filter efficiently — service_name, span_name, trace_id, is_exception are fast filters
  4. Use ->>'key' for JSON attribute access (returns text); use -> for nested JSON objects
  5. Avoid SELECT * — select only the columns you need
  6. Max 14-day range — queries cannot span more than 14 days

© pydantic, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in skills/logfire-query of pydantic/skills.

  • SKILL.md
  • references/client-usage.md
  • references/schema.md

Open the folder on GitHubat commit 238d971

Compare with similar skills

Logfire Query next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Logfire Query compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Logfire Query this skillpydantic/skills140—~2.2kAutomated safety check: PassMIT
NpgsqlrestNpgsqlRest/NpgsqlRest132—~7kAutomated safety check: NotesMIT
Sap Hana CLIsecondsky/sap-skills462—~3.1kAutomated safety check: NotesGPL-3.0
Tidewave Integrationoliver-kriska/claude-elixir-phoenix565—~1.3kAutomated safety check: PassMIT
AWS Storageaws/agent-toolkit-for-aws2.8k—~5.8kAutomated safety check: PassApache-2.0
StarRocks SQL Doc Auto-FixStarRocks/starrocks12k—~7.6kAutomated safety check: NotesApache-2.0

Similar skills

  • Npgsqlrest

    NpgsqlRest/NpgsqlRest

    Build and modify REST APIs with NpgsqlRest — exposing PostgreSQL as HTTP endpoints from two sources (database functions/procedures/tables/views, and plain .sql files), driven by SQL comment…

    132 GitHub stars~7k tokensUpdated 5 days ago
    DatabasesAuto-check: notes
  • Sap Hana CLI

    secondsky/sap-skills

    Assists with SAP HANA Developer CLI (hana-cli) for database development and administration.

    462 GitHub stars~3.1k tokensUpdated 3 days ago
    DatabasesAuto-check: notes
  • Tidewave Integration

    oliver-kriska/claude-elixir-phoenix

    Tidewave MCP runtime tools — debugging, smoke testing, live state inspection, SQL queries, hex docs.

    565 GitHub stars~1.3k tokensUpdated 2 days ago
    DatabasesAuto-check passed
  • AWS Storage

    aws/agent-toolkit-for-aws

    Official

    Selects, investigates, and compares AWS object, file, and block storage services, and answers cost, performance, configuration, security, and troubleshooting questions about storage services.

    2.8k GitHub stars~5.8k tokensUpdated today
    DatabasesAuto-check passed
  • StarRocks SQL Doc Auto-Fix

    StarRocks/starrocks

    Proposes verified fixes for failing SQL examples in StarRocks docs across three languages and several versions, then opens draft pull requests and never merges.

    12k GitHub stars~7.6k tokensUpdated today
    DatabasesAuto-check: notes
  • Schema Exploration

    timescale/pg-aiguide

    Explore an existing PostgreSQL database before answering questions about its data or writing SQL.

    1.9k GitHub stars~1.1k tokensUpdated today
    DatabasesAuto-check passed

More from pydantic/skills

All 9 skills in this repo
  • Logfire Infrastructure

    pydantic/skills

    Official

    Monitor hosts, Docker containers, Kubernetes clusters, database/queue/cache servers, and cloud-provider metrics with Pydantic Logfire — no application code required.

    140 GitHub stars~1.8k tokensUpdated 7 days ago
    Auto-check passed
  • Pydantic AI Harness

    pydantic/skills

    Official

    Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell…

    140 GitHub stars~1.9k tokensUpdated 7 days ago
    Auto-check passed
  • Official

    Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), structured output, streaming, testing, and multi-agent patterns.

    140 GitHub stars~5.4k tokensUpdated 7 days ago
    Auto-check passed
  • Logfire Evals

    pydantic/skills

    Official

    Run offline Python (pydanticevals) or Node.js (logfire/evals) evaluations and review them in Logfire.

    140 GitHub stars~3.6k tokensUpdated 7 days ago
    Auto-check passed
  • Official

    Add Pydantic Logfire observability to application code — traces, logs, metrics, and AI/agent spans.

    140 GitHub stars~6.1k tokensUpdated 7 days ago
    Auto-check passed
  • Logfire UI

    pydantic/skills

    Official

    Open or return Logfire project pages, live views, trace links, and Explore pages in the Codex browser without querying telemetry first.

    140 GitHub stars~2.9k tokensUpdated 7 days ago
    Auto-check passed

Questions about Logfire Query

What does Logfire Query do?

Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results. Logfire Query is an agent skill from pydantic/skills, published by the product's own GitHub organization. Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results.

When should I use Logfire Query?

Logfire Query fits situations like: the user asks to query logfire; look up errors in logfire; get metrics from logfire; analyze telemetry.

How do I install Logfire Query in Claude Code?

Run `npx skills add pydantic/skills --skill logfire-query -a claude-code`. Or copy the skill folder (skills/logfire-query in pydantic/skills) into .claude/skills/logfire-query in your project. Claude Code loads it when a task matches its description.

How do I install Logfire Query in Codex?

Run `npx skills add pydantic/skills --skill logfire-query -a codex`. Or copy the skill folder (skills/logfire-query in pydantic/skills) into .agents/skills/logfire-query in your project. Codex loads it when a task matches its description.

Can I use Logfire Query in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add pydantic/skills --skill logfire-query -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/logfire-query, .gemini/skills/logfire-query, .github/skills/logfire-query and .opencode/skills/logfire-query in your project.

What does Logfire Query need to run?

SKILL.md names no scripts, command-line tools or credentials: Logfire Query is instructions for the agent only. Our summary lists: Python 3.

Does Logfire Query access the network?

SKILL.md names 3 domains. In commands or code: logfire-api.pydantic.dev, logfire-us.pydantic.dev and logfire-eu.pydantic.dev; the agent is likely to contact these when it follows the instructions. This is read from the text; nothing was executed.

Is Logfire Query safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Logfire Query use?

Logfire Query is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Logfire Query use?

About 2.2k tokens (SKILL.md is roughly 9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.5k tokens, read only when the agent opens those files.

What are the alternatives to Logfire Query?

Skills that share tags, products or a category with Logfire Query: Npgsqlrest (NpgsqlRest/NpgsqlRest, 132 stars), Sap Hana CLI (secondsky/sap-skills, 462 stars), Tidewave Integration (oliver-kriska/claude-elixir-phoenix, 565 stars) and AWS Storage (aws/agent-toolkit-for-aws, 2.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Logfire Query?

pydantic (a GitHub organization, an official publisher) maintains it in pydantic/skills, which has 140 GitHub stars. The repository holds 9 skills in this directory. The repository was last updated on October 1, 2026.

Source: pydantic/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.