Skip to main content
This Helm repository contains queries to produce output that the LangSmith UI does not currently support directly (e.g. obtaining trace counts for multiple organizations in a single query). This command takes a PostgreSQL connection string that contains an embedded name and password (which can be passed in from a call to a secrets manager) and executes a query from an input file. The following example uses the pg_get_historic_trace_counts_daily.sql input file in the support_queries/postgres directory.

Prerequisites

Ensure you have the following tools/items ready.
  1. kubectl
  2. PostgreSQL client
  3. PostgreSQL database connection:
    • Host
    • Port
    • Username
      • If using the bundled version, this is postgres
    • Password
      • If using the bundled version, this is postgres
    • Database name
      • If using the bundled version, this is postgres
  4. Connectivity to the PostgreSQL database from the machine you will be running the migration script on.
    • If you are using the bundled version, you may need to port forward the postgresql service to your local machine.
    • Run kubectl port-forward svc/langsmith-postgres 5432:5432 to port forward the postgresql service to your local machine.
  5. The script to run a support query

Running the query script

Run the following command to run the desired query:
For example, if you are using the bundled version with port-forwarding, the command might look like:
which will output the count of daily traces by workspace ID and organization ID. To extract this to a file add the flag --output path/to/file.csv

Export usage data

All export methods produce the same data: LangSmith trace counts, LangSmith Deployments node usage, and Fleet run counts across all workspaces and organizations.
The UI and API exports require both of the following:
  • The organization:manage permission.
  • The caller’s email must be listed in USAGE_EXPORT_ADMIN_EMAILS, or ORG_ADMINS_INSTALLATION_USAGE_EXPORT_ENABLED must be set to true.
  1. Navigate to Settings > Usage and billing > Usage export.
  2. Click Export usage data.
  3. A ZIP file containing all usage data will download.

Export via API

If you prefer to export usage data programmatically, you can call the export API endpoint directly.

Export via SQL scripts

You can also run SQL scripts directly against your PostgreSQL database to export usage data. This requires database access credentials — no application-level permissions apply. To export trace usage (requires Helm chart version 0.11.4 or later):
To export node usage (requires Helm chart version 0.11.4 or later):
To export Fleet run counts (requires Helm chart version 0.13.25 or later):
To export usage snapshots (daily entity counts such as workspaces, projects, datasets, prompts, and active users):