> ## Documentation Index
> Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Grouping logs by field in UI requires SQL sandbox

export const plans_0 = "Any"

export const deployments_0 = "Braintrust-hosted"

export const data_plane_version_0 = undefined

export const use_case_0 = "Use case - Grouping logs by custom metadata fields in the logs viewer"

<Note>
  **Applies to:**

  * Plan - {plans_0}
  * Deployment - {deployments_0}
  * {data_plane_version_0}
  * {use_case_0}
</Note>

## Summary

**Issue:** The logs viewer display dropdown shows grouping options for custom fields, but these options don't function when selected in the UI. This is particularly problematic when trying to group traces by custom metadata fields like `thread_id` to organize related logs.

**Cause:** Grouping by custom fields is not yet implemented in the logs viewer UI, though the options appear in the dropdown.

**Resolution:** Use the SQL sandbox to group logs by custom fields until UI support is added in a future release.

## Resolution Steps

### Workaround: Use SQL sandbox

#### Step 1: Navigate to SQL sandbox

Access the SQL sandbox from your Braintrust project.

#### Step 2: Query logs with GROUP BY

Write a SQL query to group logs by your custom field.

```sql theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
SELECT
  metadata->>'thread_id' as thread_id,
  COUNT(*) as log_count,
  MIN(created) as first_log,
  MAX(created) as last_log
FROM logs
WHERE root_span = true
GROUP BY metadata->>'thread_id'
ORDER BY last_log DESC

```

#### Step 3: Analyze grouped results

Review the grouped logs to identify patterns or filter to specific groups of interest.
