Skip to content

Commit 22505e9

Browse files
Query and Metrics docs (#3074)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 84a00b6 commit 22505e9

File tree

8 files changed

+893
-10
lines changed

8 files changed

+893
-10
lines changed

docs/docs.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@
179179
}
180180
]
181181
},
182+
{
183+
"group": "Insights",
184+
"pages": ["insights/query", "insights/metrics"]
185+
},
182186
{
183187
"group": "Using the Dashboard",
184188
"pages": ["run-tests", "troubleshooting-alerts", "replaying", "bulk-actions"]
@@ -239,10 +243,7 @@
239243
},
240244
{
241245
"group": "Batches API",
242-
"pages": [
243-
"management/batches/create",
244-
"management/batches/stream-items"
245-
]
246+
"pages": ["management/batches/create", "management/batches/stream-items"]
246247
},
247248
{
248249
"group": "Runs API",
@@ -296,6 +297,10 @@
296297
"management/deployments/get-latest",
297298
"management/deployments/promote"
298299
]
300+
},
301+
{
302+
"group": "Query API",
303+
"pages": ["management/query/execute"]
299304
}
300305
]
301306
},
@@ -695,4 +700,4 @@
695700
"destination": "/migrating-from-v3"
696701
}
697702
]
698-
}
703+
}

docs/images/metrics-built-in.png

711 KB
Loading
533 KB
Loading

docs/insights/metrics.mdx

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: "Metrics dashboards"
3+
description: "Create custom dashboards with real-time metrics powered by TRQL queries."
4+
---
5+
6+
## Overview
7+
8+
In the Trigger.dev dashboard we have built-in dashboards and you can create your own.
9+
10+
Metrics dashboards are powered by [TRQL queries](/insights/query) with widgets that can be displayed as charts, tables, or single values. They automatically refresh to show the latest data.
11+
12+
![The built-in Metrics dashboard](/images/metrics-built-in.png)
13+
14+
### Visualization types
15+
16+
- **Line chart** - Show trends over time
17+
- **Bar chart** - Compare values across categories
18+
- **Area chart** - Display cumulative trends
19+
- **Table** - Show detailed data in rows
20+
- **Single value** - Display a single metric (count, sum, average, etc.)
21+
22+
You can also add Titles to your dashboard.
23+
24+
## Filtering and time ranges
25+
26+
All widgets on a dashboard use the time range filter applied to the dashboard.
27+
28+
You can also filter the data by:
29+
30+
- Scope: Environment, Project, Organization
31+
- Tasks
32+
- Queues
33+
34+
## Creating custom metrics dashboards
35+
36+
1. In the sidebar click the + icon next to "Metrics".
37+
2. Name your custom dashboard.
38+
3. From the top-right you can "Add chart" or "Add title".
39+
4. For charts you write [TRQL queries](/insights/query) and choose a visualization type.
40+
5. You can resize and reposition widgets on your dashboards.
41+
42+
## Performance considerations
43+
44+
### Optimize queries for metrics
45+
46+
1. **Use time bucketing** - `timeBucket()` automatically groups by appropriate intervals
47+
2. **Limit result size** - Add `LIMIT` clauses, especially for table widgets
48+
3. **Use approximate functions** - `uniq()` instead of `uniqExact()` for faster approximate counts
49+
50+
## Exporting metric data
51+
52+
Export data from any metric widget:
53+
54+
1. Click the widget menu (three dots)
55+
2. Select "Copy JSON" or "Copy CSV"
56+
57+
## Best practices
58+
59+
1. **Start simple** - Begin with basic metrics and iterate based on insights
60+
2. **Use meaningful names** - Give widgets clear, descriptive titles
61+
3. **Group related metrics** - Organize dashboards by theme (performance, costs, errors)
62+
4. **Test queries first** - Use the Query page to develop and test before adding to dashboards
63+
64+
## Troubleshooting
65+
66+
### Widget shows "No data"
67+
68+
- Check that your query returns results in the Query page
69+
- Verify time filters include the period with data
70+
- Ensure task/queue filters match existing runs
71+
72+
### Widget is slow to load
73+
74+
- Add time range filters to your query
75+
- Use `LIMIT` clauses
76+
- Simplify aggregations
77+
- Check query execution time in Query page
78+
79+
### Chart displays incorrectly
80+
81+
- Verify column names match visualization config
82+
- Check data types (numbers for charts, dates for time series)
83+
- Ensure `timeBucket()` is used for time-series charts
84+
- Review that series columns exist in query results
85+
86+
## Limits
87+
88+
Metrics is powered by Query so have [the same limits](/insights/query#limits) as Query.
89+
90+
There is a separate concurrency limits for metric widgets.
91+
92+
| Limit | Details |
93+
| :------------------------ | :------------- |
94+
| Concurrent widget queries | 30 per project |
95+
96+
See [Limits](/limits) for details.

0 commit comments

Comments
 (0)