Logfire

Pydantic Logfire is an observability platform built on OpenTelemetry. It collects the traces, logs, and metrics your services emit, stores every span in a queryable records table, and exposes that table through a read-only SQL API.

With Logfire, you can:

  • Search spans and logs: Filter by message text, service, span name, severity, deployment environment, and whether an exception was recorded — no SQL required.
  • Run SQL directly: Query the records and metrics tables with PostgreSQL-compatible syntax for aggregations like error rates and latency percentiles.
  • Reconstruct a request: Pull every span in a trace, ordered earliest to latest, and walk the parent-child tree to see where time went and where it failed.
  • Confirm a credential: Resolve which organization and project a read token targets before querying it.

Sim's Logfire integration lets agents read production telemetry as part of a run. Use it to triage errors against a live service, attach a root-cause summary to an incident ticket, or watch latency between deploys and page when it regresses.

Authentication uses a Logfire read token, which you create per project under Settings → Read tokens. The region is detected from the token's prefix, so Cloud users on US and EU need no extra configuration. Self-hosted instances set the Host field to their own base URL, which must be reachable over HTTPS at a publicly resolvable domain.

Usage Instructions

Integrate Pydantic Logfire into workflows. Run SQL over your observability data, search spans and logs with structured filters, pull an entire trace by ID, and confirm which project a read token targets.

Actions

logfire_query

Run a read-only SQL query against Logfire traces, logs, and metrics. Reads the records and metrics tables using PostgreSQL-compatible syntax.

Input

ParameterTypeRequiredDescription
apiKeystringYesLogfire read token
regionstringNoLogfire data region: auto, us, or eu. Auto reads the region from the token.
hoststringNoBase URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud.
sqlstringYesSQL SELECT query to run against the records or metrics table
minTimestampstringNoISO 8601 lower bound on start_timestamp. Defaults to 2020-01-01T00:00:00Z when omitted.
maxTimestampstringNoISO 8601 upper bound on start_timestamp
limitnumberNoMaximum rows to return. Logfire defaults to 100 and caps at 10000.
timezonestringNoIANA timezone used to evaluate the query, for example Europe/Paris
environmentstringNoRestrict results to a single deployment environment

Output

ParameterTypeDescription
rowsarrayResult rows. Row fields depend on the query projection.
columnsarrayColumn metadata for the result set
namestringColumn name
datatypejsonArrow datatype of the column
nullablebooleanWhether the column is nullable
rowCountnumberNumber of rows returned

logfire_search_records

Search Logfire spans and logs using structured filters for message text, service, span name, severity, environment, and exceptions. Returns the most recent matches first without writing SQL.

Input

ParameterTypeRequiredDescription
apiKeystringYesLogfire read token
regionstringNoLogfire data region: auto, us, or eu. Auto reads the region from the token.
hoststringNoBase URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud.
querystringNoCase-insensitive text to match within the record message
servicestringNoExact service name to filter on
spanNamestringNoExact span name to filter on
minLevelstringNoMinimum severity to include: trace, debug, info, notice, warn, error, or fatal
exceptionsOnlybooleanNoOnly return records that recorded an exception
environmentstringNoRestrict results to a single deployment environment
minTimestampstringNoISO 8601 lower bound on start_timestamp. Defaults to 2020-01-01T00:00:00Z when omitted.
maxTimestampstringNoISO 8601 upper bound on start_timestamp
limitnumberNoMaximum records to return. Logfire defaults to 100 and caps at 10000.

Output

ParameterTypeDescription
rowsarrayMatching spans and logs, most recent first
startTimestampstringUTC time the span started
endTimestampstringUTC time the span ended
durationnumberSpan duration in seconds. Null for logs.
levelstringSeverity name, such as info, warn, or error
messagestringHuman-readable message
spanNamestringTemplate label for similar records
kindstringRecord kind: span, log, or span_event
serviceNamestringService that emitted the record
deploymentEnvironmentstringDeployment environment of the record
traceIdstringTrace this record belongs to
spanIdstringIdentifier of this span
parentSpanIdstringParent span identifier
isExceptionbooleanWhether an exception was recorded on the span
exceptionTypestringFully qualified exception class name
exceptionMessagestringException message
rowCountnumberNumber of rows returned
sqlstringSQL query that was executed against Logfire

logfire_get_trace

Fetch every span and log belonging to a Logfire trace, ordered from earliest to latest, so a single request can be reconstructed end to end.

Input

ParameterTypeRequiredDescription
apiKeystringYesLogfire read token
regionstringNoLogfire data region: auto, us, or eu. Auto reads the region from the token.
hoststringNoBase URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud.
traceIdstringYes32-character hexadecimal trace identifier
minTimestampstringNoISO 8601 lower bound on start_timestamp. Defaults to 2020-01-01T00:00:00Z when omitted.
maxTimestampstringNoISO 8601 upper bound on start_timestamp
limitnumberNoMaximum spans to return. Logfire defaults to 100 and caps at 10000.

Output

ParameterTypeDescription
rowsarraySpans and logs in the trace, earliest first
startTimestampstringUTC time the span started
endTimestampstringUTC time the span ended
durationnumberSpan duration in seconds. Null for logs.
levelstringSeverity name, such as info, warn, or error
messagestringHuman-readable message
spanNamestringTemplate label for similar records
kindstringRecord kind: span, log, or span_event
serviceNamestringService that emitted the record
deploymentEnvironmentstringDeployment environment of the record
traceIdstringTrace this record belongs to
spanIdstringIdentifier of this span
parentSpanIdstringParent span identifier
isExceptionbooleanWhether an exception was recorded on the span
exceptionTypestringFully qualified exception class name
exceptionMessagestringException message
rowCountnumberNumber of rows returned
sqlstringSQL query that was executed against Logfire

logfire_get_token_info

Resolve which Logfire organization and project a read token belongs to. Useful for confirming a credential targets the expected project before querying it.

Input

ParameterTypeRequiredDescription
apiKeystringYesLogfire read token
regionstringNoLogfire data region: auto, us, or eu. Auto reads the region from the token.
hoststringNoBase URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud.

Output

ParameterTypeDescription
organizationNamestringLogfire organization the read token belongs to
projectNamestringLogfire project the read token belongs to

On this page