Loading...
Loading...
Query Logfire telemetry data — traces, logs, spans, and metrics. 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", or wants to add Logfire querying capabilities to their code. Also use when the user wants to explore OpenTelemetry data, investigate production issues by querying, or build dashboards/reports from Logfire data.
npx skill4agent add pydantic/skills logfire-query| Aspect | MCP | REST API |
|---|---|---|
| Best for | Interactive exploration in Claude | Adding query code to a project |
| Auth | OAuth via MCP session | Bearer read token |
| Setup | Already configured via plugin | Need a read token |
| Formats | JSON rows | JSON, CSV, Apache Arrow |
| Default window | Last 30 min | Last 24 hours |
| Max range | 14 days | 14 days |
| Row limit | Must be in SQL | Default 500, max 10,000 |
records| Column | Type | Description |
|---|---|---|
| timestamp (UTC) | When span/log was created |
| timestamp (UTC) | When span/log completed |
| double (seconds) | Time between start and end; NULL for logs |
| string (32 hex) | Unique trace identifier |
| string (16 hex) | Unique span identifier |
| string (16 hex) | Parent span; NULL for root spans |
| string | Low-cardinality label for similar records |
| string | Human-readable description with arguments filled in |
| integer | Severity (supports |
| string | |
| string | Service identifier |
| boolean | Whether an exception was recorded |
| string | Exception class name |
| string | Exception message |
| string | Full traceback |
| JSON | Structured data; query with |
| string[] | Grouping labels; query with |
| integer | HTTP status code |
| string | HTTP method |
| string | HTTP route pattern |
| string | Span status |
metrics| Column | Type | Description |
|---|---|---|
| timestamp (UTC) | When metric was recorded |
| string | Metric name |
| string | Type (gauge, counter, histogram) |
| string | Unit of measurement |
| double | Metric value |
| string | Service identifier |
| JSON | Metric dimensions |
references/schema.md-- 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 bucketquery_runqueryprojectmin_timestampmax_timestampLIMIT-- 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 DESCGET https://logfire-api.pydantic.dev/v1/queryhttps://logfire-us.pydantic.dev/v1/queryhttps://logfire-eu.pydantic.dev/v1/queryAuthorization: Bearer <read_token>sqlmin_timestampmax_timestamplimitAcceptapplication/jsonapplication/jsonrow_oriented=truetext/csvapplication/vnd.apache.arrow.streamLogfireQueryClientAsyncLogfireQueryClientlogfire.db_apireferences/client-usage.mdmin_timestampmax_timestampWHEREservice_namespan_nametrace_idis_exception->>'key'->SELECT *