From 19b710fb68bf2ab7e79cf883a81fd773f3df9edc Mon Sep 17 00:00:00 2001 From: Drew Davis Date: Mon, 15 Dec 2025 09:32:43 -0500 Subject: [PATCH] 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. --- .changeset/quick-insects-shop.md | 5 +++++ packages/app/src/ServicesDashboardPage.tsx | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 .changeset/quick-insects-shop.md diff --git a/.changeset/quick-insects-shop.md b/.changeset/quick-insects-shop.md new file mode 100644 index 00000000..e24fe2e7 --- /dev/null +++ b/.changeset/quick-insects-shop.md @@ -0,0 +1,5 @@ +--- +"@hyperdx/app": patch +--- + +fix: Update Request Error Rate config to use MVs diff --git a/packages/app/src/ServicesDashboardPage.tsx b/packages/app/src/ServicesDashboardPage.tsx index a8f74a95..b3f9b929 100644 --- a/packages/app/src/ServicesDashboardPage.tsx +++ b/packages/app/src/ServicesDashboardPage.tsx @@ -342,8 +342,21 @@ function HttpTab({ whereLanguage: appliedConfig.whereLanguage || 'sql', displayType: DisplayType.Line, select: [ + // Separate the aggregations from the rate calculation so that AggregatingMergeTree MVs can be used { - valueExpression: `countIf(${expressions.isError}) / count()`, + valueExpression: '', + aggFn: 'count', + alias: 'total_requests', + }, + { + valueExpression: '', + aggFn: 'count', + aggCondition: expressions.isError, + aggConditionLanguage: 'sql', + alias: 'error_requests', + }, + { + valueExpression: `error_requests / total_requests`, alias: 'error_rate', }, ], @@ -502,6 +515,7 @@ function HttpTab({ {source && requestErrorRateConfig && (