Skip to content

feat: Logfire query CLI tool for production log debugging#14

Merged
rezhajulio merged 6 commits into
mainfrom
feat/logfire-query-tool
Jun 11, 2026
Merged

feat: Logfire query CLI tool for production log debugging#14
rezhajulio merged 6 commits into
mainfrom
feat/logfire-query-tool

Conversation

@rezhajulio

@rezhajulio rezhajulio commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

Add a standalone CLI script to query Pydantic Logfire logs for AI agent debugging.

Features

  • Pre-built query templates for common debug patterns (errors, warnings, slow spans, user/group activity)
  • Free-form SQL for ad-hoc investigation
  • Auto-detect EU/US endpoint from token prefix (pylf_v1_eu → EU)
  • Auto-load .env via python-dotenv
  • Text and JSON output formats
  • Read token fallback — checks LOGFIRE_READ_TOKEN first, then LOGFIRE_TOKEN

Config

Env Var Required Default Description
LOGFIRE_READ_TOKEN Yes Read token from Logfire project settings
LOGFIRE_API_URL No Auto-detected API endpoint (auto-detects EU from token)
LOGFIRE_LIMIT No 50 Default result limit
LOGFIRE_MINUTES No 30 Default time window

Technical Notes

  • Uses Logfire v2 SQL query API ()
  • Always sends parameter (required by API; defaults to 2020-01-01 for full data range)
  • Sets header (API returns Arrow by default)
  • SQL injection prevented: and are
  • 32 unit tests with mocked API responses

Files Changed

  • scripts/query_logs.py — new CLI script (~280 lines)
  • tests/test_query_logs.py — new test file (32 tests)
  • .gitignore — allow docs/REVIEW-FIXES.md

@rezhajulio rezhajulio merged commit 065918d into main Jun 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant