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

# Grouping logs by field in UI requires the Query page

> [!NOTE]
>
> **Applies to:**
>
> * Plan - Any
> * Deployment - Braintrust-hosted
> *
> * Use case - Grouping logs by custom metadata fields in the logs viewer

## 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 Query page to group logs by custom fields until UI support is added in a future release.

## Resolution Steps

### Workaround: Use the Query page

#### Step 1: Go to the Query page

Go to the [** Query**](https://www.braintrust.dev/app/~/sql) page in 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.