Query Client
Bases: _BaseLogfireQueryClient[Client]
A synchronous client for querying Logfire data.
def info() -> ReadTokenInfo
Get information about the read token.
ReadTokenInfo
def query_json_rows(
sql: str,
min_timestamp: None = None,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> RowQueryResults
def query_json_rows(
sql: str,
min_timestamp: datetime,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> RowQueryResults
Query Logfire data and return the results as a row-oriented dictionary.
RowQueryResults — A dictionary with two entries:
columns: A list of column details including the name, datatype and whether the column is nullable.rows: The list of rows matching the query.
sql : str
The SQL SELECT query to execute.
The minimum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
Not providing a min_timestamp is deprecated.
The maximum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
The maximum number of rows to query. This value takes priority over the
LIMIT clause in the sql query.
The timezone to use for the query execution context.
Restrict rows to the provided environment(s). To only query rows where no environment is set,
use the empty string ('').
def query_arrow(
sql: str,
min_timestamp: None = None,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> Table
def query_arrow(
sql: str,
min_timestamp: datetime,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> Table
Query Logfire data and return the results as a pyarrow Table.
Note that pyarrow must be installed for this method to succeed.
You can use polars.from_arrow(result) to convert the returned table to a polars DataFrame.
Table
sql : str
The SQL SELECT query to execute.
The minimum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
Not providing a min_timestamp is deprecated.
The maximum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
The maximum number of rows to query. This value takes priority over the
LIMIT clause in the sql query.
The timezone to use for the query execution context.
Restrict rows to the provided environment(s). To only query rows where no environment is set,
use the empty string ('').
def query_csv(
sql: str,
min_timestamp: None = None,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> str
def query_csv(
sql: str,
min_timestamp: datetime,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> str
Query Logfire data and return the results as a CSV-format string.
Use polars.read_csv(StringIO(result)) to convert the returned CSV to a polars DataFrame.
sql : str
The SQL SELECT query to execute.
The minimum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
Not providing a min_timestamp is deprecated.
The maximum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
The maximum number of rows to query. This value takes priority over the
LIMIT clause in the sql query.
The timezone to use for the query execution context.
Restrict rows to the provided environment(s). To only query rows where no environment is set,
use the empty string ('').
Bases: _BaseLogfireQueryClient[AsyncClient]
An asynchronous client for querying Logfire data.
@async
def info() -> ReadTokenInfo
Get information about the read token.
ReadTokenInfo
@async
def query_json_rows(
sql: str,
min_timestamp: None = None,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> RowQueryResults
def query_json_rows(
sql: str,
min_timestamp: datetime,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> RowQueryResults
Query Logfire data and return the results as a row-oriented dictionary.
RowQueryResults — A dictionary with two entries:
columns: A list of column details including the name, datatype and whether the column is nullable.rows: The list of rows matching the query.
sql : str
The SQL SELECT query to execute.
The minimum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
Not providing a min_timestamp is deprecated.
The maximum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
The maximum number of rows to query. This value takes priority over the
LIMIT clause in the sql query.
The timezone to use for the query execution context.
Restrict rows to the provided environment(s). To only query rows where no environment is set,
use the empty string ('').
@async
def query_arrow(
sql: str,
min_timestamp: None = None,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> Table
def query_arrow(
sql: str,
min_timestamp: datetime,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> Table
Query Logfire data and return the results as a pyarrow Table.
Note that pyarrow must be installed for this method to succeed.
You can use polars.from_arrow(result) to convert the returned table to a polars DataFrame.
Table
sql : str
The SQL SELECT query to execute.
The minimum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
Not providing a min_timestamp is deprecated.
The maximum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
The maximum number of rows to query. This value takes priority over the
LIMIT clause in the sql query.
The timezone to use for the query execution context.
Restrict rows to the provided environment(s). To only query rows where no environment is set,
use the empty string ('').
@async
def query_csv(
sql: str,
min_timestamp: None = None,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> str
def query_csv(
sql: str,
min_timestamp: datetime,
max_timestamp: datetime | None = None,
limit: int | None = None,
timezone: str | None = None,
environment: str | list[str] | None = None,
) -> str
Query Logfire data and return the results as a CSV-format string.
Use polars.read_csv(StringIO(result)) to convert the returned CSV to a polars DataFrame.
sql : str
The SQL SELECT query to execute.
The minimum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
Not providing a min_timestamp is deprecated.
The maximum timestamp to use when querying data. If the provided
datetime doesn’t have a timezone set, it is assumed to
be UTC.
The maximum number of rows to query. This value takes priority over the
LIMIT clause in the sql query.
The timezone to use for the query execution context.
Restrict rows to the provided environment(s). To only query rows where no environment is set,
use the empty string ('').
Bases: TypedDict
Information about the read token.
Bases: TypedDict
The row-oriented results of a JSON-format query.
The list of column details (e.g. [{"name": "service_name", "datatype": "Utf8", "nullable": false}]).
Type: list[ColumnDetails]
The list of rows matching the query (e.g. [{"service_name": "backend"}]).
Bases: TypedDict
The details of a column in the row-oriented JSON-format query results.
The name of the column.
Type: str
The datatype of the column.
Type: Any
Whether the column is nullable or not.
Type: bool