Skip to content

SDK Command Line Interface

Logfire comes with a CLI used for authentication and project management:

usage: logfire [-h] [--version] [--region {us,eu}]  ...

The CLI for Pydantic Logfire.

options:
  -h, --help        show this help message and exit
  --version         show the version and exit

global options:
  --region {us,eu}  the region to use

commands:

    auth            Authenticate with Logfire.
    clean           Remove the contents of the Logfire data directory.
    inspect         Inspect installed packages and recommend packages that
                    might be useful.
    whoami          Show user authenticated username and the URL to your
                    Logfire project.
    projects        Project management for Logfire.
    info            Show versions of logfire, OS and related packages.

See https://logfire.pydantic.dev/docs/reference/cli/ for more detailed
documentation.

Authentication (auth)

You need to be authenticated to use the Logfire.

Abstract

Read the Terms of Service and Privacy Policy if you want to know how we handle your data. ๐Ÿค“

To authenticate yourself, run the auth command in the terminal:

logfire auth

You will be prompted to select a data region (EU or US). To specify this via the cli instead of interactively, use logfire --region eu auth or logfire --region eu auth

Then you will be given the option to open logfire in your browser: Terminal screenshot with Logfire auth command

After pressing "Enter", you will be redirected to the browser to log in to your account.

Browser screenshot with Logfire login page

Then, if you go back to the terminal, you'll see that you are authenticated! ๐ŸŽ‰

Terminal screenshot with successful authentication

Clean (clean)

To clean most the files created by Logfire, run the following command:

logfire clean

The clean command doesn't remove the logs, and the authentication information stored in the ~/.logfire directory.

To also remove the logs, you can run the following command:

logfire clean --logs

Inspect (inspect)

The inspect command is used to identify the missing OpenTelemetry instrumentation packages in your project.

To inspect your project, run the following command:

logfire inspect

This will output the projects you need to install to have optimal OpenTelemetry instrumentation.

Terminal screenshot with Logfire inspect command

Who Am I (whoami)

๐Ÿšง Work in Progress ๐Ÿšง

This section is yet to be written, contact us if you have any questions.

Projects

List (projects list)

To check the projects you have access to, run the following command:

logfire projects list

You'll see something like this:

โฏ logfire projects list
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Organization โ”ƒ Project        โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Kludex       โ”‚ backend        โ”‚
โ”‚ Kludex       โ”‚ worker         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Use (projects use)

To use an already created project, run the following command:

logfire projects use <project-name>

For example, to use the backend project, you can run:

logfire projects use backend

Create (projects new)

To create a new project, run the following command:

logfire projects new <project-name>

Follow the instructions, and you'll have a new project created in no time! ๐Ÿฅณ