pg_get_trace_counts_daily.sql input file in the support_queries/postgres directory.
Prerequisites
Ensure you have the following tools/items ready.- kubectl
- PostgreSQL client
-
PostgreSQL database connection:
- Host
- Port
- Username
- If using the bundled version, this is
postgres
- If using the bundled version, this is
- Password
- If using the bundled version, this is
postgres
- If using the bundled version, this is
- Database name
- If using the bundled version, this is
postgres
- If using the bundled version, this is
-
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:5432to port forward the postgresql service to your local machine.
-
The script to run a support query
- Download the PostgreSQL support query script
Running the query script
Run the following command to run the desired query:--output path/to/file.csv
Export usage data
All export methods produce the same data: LangSmith trace counts, LangSmith Deployments node usage, and Agent Builder run counts across all workspaces and organizations.The UI and API exports require both of the following:
- The
organization:managepermission. - The caller’s email must be listed in
USAGE_EXPORT_ADMIN_EMAILS, orORG_ADMINS_INSTALLATION_USAGE_EXPORT_ENABLEDmust be set totrue.
Export from the UI (recommended)
- Navigate to Settings > Usage and billing > Usage export.
- Click Export usage data.
- 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):Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

