Skip to content

Commit 19b710f

Browse files
authored
fix: Update Services Dashboard count() queries to correctly use MVs (#1473)
Closes HDX-3057 This PR updates the Request Error Rate query config so that it can correctly leverage materialized views.
1 parent 96f0539 commit 19b710f

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎.changeset/quick-insects-shop.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
fix: Update Request Error Rate config to use MVs

‎packages/app/src/ServicesDashboardPage.tsx‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,21 @@ function HttpTab({
342342
whereLanguage: appliedConfig.whereLanguage || 'sql',
343343
displayType: DisplayType.Line,
344344
select: [
345+
// Separate the aggregations from the rate calculation so that AggregatingMergeTree MVs can be used
345346
{
346-
valueExpression: `countIf(${expressions.isError}) / count()`,
347+
valueExpression: '',
348+
aggFn: 'count',
349+
alias: 'total_requests',
350+
},
351+
{
352+
valueExpression: '',
353+
aggFn: 'count',
354+
aggCondition: expressions.isError,
355+
aggConditionLanguage: 'sql',
356+
alias: 'error_requests',
357+
},
358+
{
359+
valueExpression: `error_requests / total_requests`,
347360
alias: 'error_rate',
348361
},
349362
],
@@ -502,6 +515,7 @@ function HttpTab({
502515
{source && requestErrorRateConfig && (
503516
<DBTimeChart
504517
sourceId={source.id}
518+
hiddenSeries={['total_requests', 'error_requests']}
505519
config={requestErrorRateConfig}
506520
showDisplaySwitcher={false}
507521
disableQueryChunking
@@ -1278,7 +1292,8 @@ function ErrorsTab({
12781292
displayType: DisplayType.StackedBar,
12791293
select: [
12801294
{
1281-
valueExpression: `count()`,
1295+
valueExpression: '',
1296+
aggFn: 'count',
12821297
},
12831298
],
12841299
numberFormat: INTEGER_NUMBER_FORMAT,

0 commit comments

Comments
 (0)