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 direct connect docs #26

Merged
merged 3 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions docs/guides/advanced/06_direct_database_connections.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
!!! warning "🚧 Work in Progress 🚧"
This page is yet to be written, [contact us](../../help.md) if you have any questions.
# Direct Database Connections

The Logfire platform allows you to connect and run SQL queries against your data using PostgreSQL syntax.
Kludex marked this conversation as resolved.
Show resolved Hide resolved

By doing this, you can connect your existing tools such as Grafana, Metabase, Superset, or anything else with support for querying PostgreSQL sources.

## Generating credentials

To connect, you'll first need to generate generate Database Credentials from your project page at `https://logfire.pydantic.dev/<organization>/<project>/settings/database-credentials`
Kludex marked this conversation as resolved.
Show resolved Hide resolved

![Creating database credentials](../../images/guide/direct-connect-credentials.png)

The credentials generated are a PostgreSQL URI which can be used as a connection string for compatible tools. These will only be shown by the Logfire platform once, so save them to a secure location for future use!

## Example: pgcli

`pgcli` is a command-line tool to access PostgreSQL databases.
Kludex marked this conversation as resolved.
Show resolved Hide resolved

Using the credentials generated in the previous step as the argument to `pgcli`, you can connect directly to logfire:
Kludex marked this conversation as resolved.
Show resolved Hide resolved

```
$ pgcli postgresql://<user>:<password>@db.logfire.dev:5432/proj_david-test # REDACTED
Version: 4.0.1
Home: http://pgcli.com
proj_david-test> select start_timestamp, message from records limit 10;
+-------------------------------+----------------------------------------+
| start_timestamp | message |
|-------------------------------+----------------------------------------|
| 2024-04-28 10:50:41.681886+00 | action=view-faq size=549 i=0 |
| 2024-04-28 10:50:41.711747+00 | GET /contact/ http send response.body |
| 2024-04-28 10:50:41.665576+00 | GET /contact/ |
| 2024-04-28 10:50:41.711119+00 | GET /contact/ http send response.start |
| 2024-04-28 10:50:41.709458+00 | response 500 |
| 2024-04-28 10:50:38.50534+00 | action=view-cart size=517 i=0 |
| 2024-04-28 10:50:39.446668+00 | action=view-faq size=637 i=2 |
| 2024-04-28 10:50:38.681198+00 | action=view-terms size=216 i=3 |
| 2024-04-28 10:50:39.416706+00 | action=view-product size=380 i=0 |
| 2024-04-28 10:50:38.394237+00 | sub-sub-sub-action=logout |
+-------------------------------+----------------------------------------+
SELECT 10
Time: 0.218s
```

With the flexibility of PostgreSQL access available to you, we can't wait to hear what you do with the Logfire platform!
Binary file added docs/images/guide/direct-connect-credentials.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.