Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for the Logfire Query API #405

Merged
merged 15 commits into from
Aug 30, 2024
Merged

Conversation

dmontagu
Copy link
Contributor

@dmontagu dmontagu commented Aug 28, 2024

Query API

Logfire now provides a web API for programmatically running arbitrary SQL queries against the data in your Logfire projects.

This API can be used to retrieve data for export, analysis, or integration with other tools, allowing you to leverage
your data in a variety of ways.

The API is available at https://logfire-api.pydantic.dev/v1/query and requires a read token for authentication.
You will be soon able to generate read tokens from the Logfire web interface (this is described in more detail in the docs added in this PR).

The API can return data in various formats, including JSON, Apache Arrow, and CSV.

Changes in this PR:

This PR adds documentation of how to make HTTP requests to this API directly, and also adds sync and async clients in logfire.experimental.query_client to make it convenient to write code leveraging these APIs from python.

The clients are being included under the logfire.experimental namespace for now to indicate that they may be subject to breaking changes, though we do not have any such changes planned at this time and will try to avoid them as much as possible.

Copy link

cloudflare-workers-and-pages bot commented Aug 29, 2024

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 04b3a18
Status: ✅  Deploy successful!
Preview URL: https://77217d26.logfire-docs.pages.dev
Branch Preview URL: https://dmontagu-read-tokens-docs.logfire-docs.pages.dev

View logs

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a404923) to head (04b3a18).

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #405    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          128       130     +2     
  Lines         9355      9499   +144     
  Branches      1217      1230    +13     
==========================================
+ Hits          9355      9499   +144     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

docs/guides/advanced/index.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
@Kludex
Copy link
Member

Kludex commented Aug 30, 2024

Should I block this bot from the organization?

@dmontagu dmontagu changed the title Add docs for read tokens functionality Add documentation for the Logfire Query API Aug 30, 2024
docs/guides/advanced/index.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
docs/guides/advanced/query_api.md Show resolved Hide resolved
Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style_guide_test.md review details

Line Edit Problems/Proposals

Note: The following 3 comments are grouped by line.

Line 3

Existing text:

# This ia a test file

Issues:

  • Style Guide - (Spelling-error) Did you really mean 'ia'?

Line 5

Existing text:

it will flag errors like on pydantic.

Issues:

  • Style Guide - (Terms-error) Use 'Pydantic' instead of 'pydantic'.

Line 11

Existing text:

This is is an issue.

Issues:

  • Style Guide - (Repetition-error) 'is' is repeated!
  • Style Guide - (hyperlint.repeatedWords-error) 'is' is repeated, did you mean to repeat this word?

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style_guide_test.md review details

Line Edit Problems/Proposals

Note: The following 3 comments are grouped by line.

Line 3

Existing text:

# This ia a test file

Issues:

  • Style Guide - (Spelling-error) Did you really mean 'ia'?

Line 5

Existing text:

it will flag errors like on pydantic.

Issues:

  • Style Guide - (Terms-error) Use 'Pydantic' instead of 'pydantic'.

Line 11

Existing text:

This is is an issue.

Issues:

  • Style Guide - (Repetition-error) 'is' is repeated!
  • Style Guide - (hyperlint.repeatedWords-error) 'is' is repeated, did you mean to repeat this word?

@dmontagu dmontagu merged commit 95a43d4 into main Aug 30, 2024
15 checks passed
@dmontagu dmontagu deleted the dmontagu/read-tokens-docs branch August 30, 2024 17:02

If no `Accept` header is provided, the default response format is JSON.

- **Query Parameters**:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't render properly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and sql needs to be included.

# Set the headers for authentication
headers = {
'Authorization': f'Bearer {read_token}',
'Content-Type': 'application/json'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be Accept, not Content-Type

- `application/vnd.apache.arrow.stream`: Returns the data in Apache Arrow format, suitable for high-performance data processing.
- `text/csv`: Returns the data in CSV format, which is easy to use with many data tools.

If no `Accept` header is provided, the default response format is JSON.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be required.

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.

5 participants