Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(metrics): count distinct values in group-by attributes (#100138)

Frank Hamand05f1e833ae28
diff --git a/docs/internal/metrics-group-by.md b/docs/internal/metrics-group-by.md
index 89363d5139a3..cc4687926ec6 100644
--- a/docs/internal/metrics-group-by.md
+++ b/docs/internal/metrics-group-by.md
@@ -1,19 +1,22 @@
# Metrics group by
-The Group by dropdown lists attributes by series count, from highest to lowest.
-Each item shows its series count on the right.
-Hover over a count to show the "Number of series with this attribute" tooltip.
+The Group by dropdown lists attributes by distinct value count, from highest to lowest.
+Each item shows its distinct value count on the right.
+Hover over a count to show the "Number of distinct values" tooltip.
Attributes with the same count appear in alphabetical order.
Search keeps this order.
-The count uses distinct series whose latest metadata timestamp is at or after the selected start time, across the project.
+The count uses attribute values from series whose latest metadata timestamp is at or after the selected start time.
It does not read raw metric samples or enforce the selected end time.
Counts are informational and most useful for recent series.
+The query uses `uniqCombined64` to estimate distinct value counts with bounded memory.
Metadata updates can lag samples, so this is not an exact count for the selected time window.
When a metric is selected, it only lists attributes from that metric.
When no metric is selected, it lists attributes from all metrics in the project.
The count includes both metric attributes and resource attributes.
-An attribute that occurs in both scopes counts once per series.
-The `service_name` item uses the same count and order as other attributes.
+Repeated values count once, even when many series have the same value.
+For an attribute in both scopes, the nonempty resource value takes priority, as it does in chart grouping.
+Otherwise, the count uses the metric attribute value. An empty string counts as one value.
+The `service_name` item counts distinct service names, not series.
Users can still enter custom attribute keys. Custom keys have no count until the API returns them.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index be98be1c1ace..3bf042032bd0 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5481,9 +5481,9 @@ snapshots:
mcp-apps-workflows--list--light:
hash: v1.k794b7964.05ea602d6d9345842a6335a7a5dfd2708b35e7e84582dedab2d4f75daab793c5.R8GtNbF9pB7JrXdEIBpk8XsgLhKJuKMA1UB9qr0Tzbs
metrics-group-by--default--dark:
- hash: v1.k794b7964.ee00c0f572067d18b53141dce72c182c640f399bd746abce9b2098503dbb62aa.Bkt1qCLQus_6z8XlmJ6Ax5cQjvOkEdyrQDtZKyV_KJY
+ hash: v1.k794b7964.ce83d5c6298b08ac62a7eeb1365881f3eaad9e77a2ffc762a8683bb5360cf49f.ZybY7nObSqgkgX4qZO0IbHSimFba2tRWMI3lKApT73o
metrics-group-by--default--light:
- hash: v1.k794b7964.e5d6a1978e274f76e13a0476f07c2956302b2b84bc318e38c55c72bd2839d8e9.sZnt-HOnAKGE8421CprrJcFq9wQut5SU7DSEi_6Kqiw
+ hash: v1.k794b7964.6569c85c82c01e61526ea93e8d61158da38a1c465eac8cafad2b87e2d09a287a.RVDxyDYqLRvzRQdz3BZmwkiYQQ0pCllfzH6Z5xQJiGw
metrics-metricscatalog--default--dark:
hash: v1.k794b7964.a1464d9a9bef8d961229aa836b02bba22e3baf5683fd6928bad2043e661fb63c.uJFa3cShWZCenILbuE_EpT0yJMsK1lbSZhPfe0ghE0Y
metrics-metricscatalog--default--light:
diff --git a/posthog/hogql/functions/aggregations.py b/posthog/hogql/functions/aggregations.py
index f96066d8d3ed..6799c620eec1 100644
--- a/posthog/hogql/functions/aggregations.py
+++ b/posthog/hogql/functions/aggregations.py
@@ -263,7 +263,7 @@ HOGQL_AGGREGATIONS: dict[str, HogQLFunctionMeta] = {
"uniqExactIf": HogQLFunctionMeta("uniqExactIf", 2, None, aggregate=True),
"uniqCombined": HogQLFunctionMeta("uniqCombined", 1, None, aggregate=True),
# "uniqCombinedIf": HogQLFunctionMeta("uniqCombinedIf", 2, 2, aggregate=True),
- # "uniqCombined64": HogQLFunctionMeta("uniqCombined64", 1, 1, aggregate=True),
+ "uniqCombined64": HogQLFunctionMeta("uniqCombined64", 1, None, aggregate=True),
# "uniqCombined64If": HogQLFunctionMeta("uniqCombined64If", 2, 2, aggregate=True),
"uniqHLL12": HogQLFunctionMeta("uniqHLL12", 1, None, aggregate=True),
"uniqHLL12If": HogQLFunctionMeta("uniqHLL12If", 2, None, aggregate=True),
diff --git a/posthog/hogql/printer/test/__snapshots__/test_trino_printer.ambr b/posthog/hogql/printer/test/__snapshots__/test_trino_printer.ambr
index 0474ced1bced..9d6a2ff4c792 100644
--- a/posthog/hogql/printer/test/__snapshots__/test_trino_printer.ambr
+++ b/posthog/hogql/printer/test/__snapshots__/test_trino_printer.ambr
@@ -280,6 +280,7 @@
'theilsU',
'theilsUIf',
'uniqCombined',
+ 'uniqCombined64',
'uniqExactMerge',
'uniqExactState',
'uniqHLL12',
diff --git a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr
index 7cc43be1c0b5..44d88249b1e7 100644
--- a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr
+++ b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr
@@ -69,7 +69,7 @@
These are the aggregated HogQL functions:
```
- ['avgIf', 'avgArray', 'avgArrayIf', 'avgArrayOrDefault', 'avgArrayOrDefaultIf', 'avgArrayOrNull', 'avgArrayOrNullIf', 'avgMap', 'avgMapIf', 'avgMapOrDefault', 'avgMapOrDefaultIf', 'avgMapOrNull', 'avgMapOrNullIf', 'avgState', 'avgStateIf', 'avgStateOrDefault', 'avgStateOrDefaultIf', 'avgStateOrNull', 'avgStateOrNullIf', 'avgMerge', 'avgMergeIf', 'avgMergeOrDefault', 'avgMergeOrDefaultIf', 'avgMergeOrNull', 'avgMergeOrNullIf', 'avgForEach', 'avgForEachIf', 'avgForEachOrDefault', 'avgForEachOrDefaultIf', 'avgForEachOrNull', 'avgForEachOrNullIf', 'avgOrDefault', 'avgOrDefaultIf', 'avgOrNull', 'avgOrNullIf', 'avgArgMin', 'avgArgMinIf', 'avgArgMinOrDefault', 'avgArgMinOrDefaultIf', 'avgArgMinOrNull', 'avgArgMinOrNullIf', 'avgArgMax', 'avgArgMaxIf', 'avgArgMaxOrDefault', 'avgArgMaxOrDefaultIf', 'avgArgMaxOrNull', 'avgArgMaxOrNullIf', 'sumIf', 'sumArray', 'sumArrayIf', 'sumArrayOrDefault', 'sumArrayOrDefaultIf', 'sumArrayOrNull', 'sumArrayOrNullIf', 'sumMap', 'sumMapIf', 'sumMapOrDefault', 'sumMapOrDefaultIf', 'sumMapOrNull', 'sumMapOrNullIf', 'sumState', 'sumStateIf', 'sumStateOrDefault', 'sumStateOrDefaultIf', 'sumStateOrNull', 'sumStateOrNullIf', 'sumMerge', 'sumMergeIf', 'sumMergeOrDefault', 'sumMergeOrDefaultIf', 'sumMergeOrNull', 'sumMergeOrNullIf', 'sumForEach', 'sumForEachIf', 'sumForEachOrDefault', 'sumForEachOrDefaultIf', 'sumForEachOrNull', 'sumForEachOrNullIf', 'sumOrDefault', 'sumOrDefaultIf', 'sumOrNull', 'sumOrNullIf', 'sumArgMin', 'sumArgMinIf', 'sumArgMinOrDefault', 'sumArgMinOrDefaultIf', 'sumArgMinOrNull', 'sumArgMinOrNullIf', 'sumArgMax', 'sumArgMaxIf', 'sumArgMaxOrDefault', 'sumArgMaxOrDefaultIf', 'sumArgMaxOrNull', 'sumArgMaxOrNullIf', 'minIf', 'minArray', 'minArrayIf', 'minArrayOrDefault', 'minArrayOrDefaultIf', 'minArrayOrNull', 'minArrayOrNullIf', 'minMap', 'minMapIf', 'minMapOrDefault', 'minMapOrDefaultIf', 'minMapOrNull', 'minMapOrNullIf', 'minState', 'minStateIf', 'minStateOrDefault', 'minStateOrDefaultIf', 'minStateOrNull', 'minStateOrNullIf', 'minMerge', 'minMergeIf', 'minMergeOrDefault', 'minMergeOrDefaultIf', 'minMergeOrNull', 'minMergeOrNullIf', 'minForEach', 'minForEachIf', 'minForEachOrDefault', 'minForEachOrDefaultIf', 'minForEachOrNull', 'minForEachOrNullIf', 'minOrDefault', 'minOrDefaultIf', 'minOrNull', 'minOrNullIf', 'minArgMin', 'minArgMinIf', 'minArgMinOrDefault', 'minArgMinOrDefaultIf', 'minArgMinOrNull', 'minArgMinOrNullIf', 'minArgMax', 'minArgMaxIf', 'minArgMaxOrDefault', 'minArgMaxOrDefaultIf', 'minArgMaxOrNull', 'minArgMaxOrNullIf', 'maxIf', 'maxArray', 'maxArrayIf', 'maxArrayOrDefault', 'maxArrayOrDefaultIf', 'maxArrayOrNull', 'maxArrayOrNullIf', 'maxMap', 'maxMapIf', 'maxMapOrDefault', 'maxMapOrDefaultIf', 'maxMapOrNull', 'maxMapOrNullIf', 'maxState', 'maxStateIf', 'maxStateOrDefault', 'maxStateOrDefaultIf', 'maxStateOrNull', 'maxStateOrNullIf', 'maxMerge', 'maxMergeIf', 'maxMergeOrDefault', 'maxMergeOrDefaultIf', 'maxMergeOrNull', 'maxMergeOrNullIf', 'maxForEach', 'maxForEachIf', 'maxForEachOrDefault', 'maxForEachOrDefaultIf', 'maxForEachOrNull', 'maxForEachOrNullIf', 'maxOrDefault', 'maxOrDefaultIf', 'maxOrNull', 'maxOrNullIf', 'maxArgMin', 'maxArgMinIf', 'maxArgMinOrDefault', 'maxArgMinOrDefaultIf', 'maxArgMinOrNull', 'maxArgMinOrNullIf', 'maxArgMax', 'maxArgMaxIf', 'maxArgMaxOrDefault', 'maxArgMaxOrDefaultIf', 'maxArgMaxOrNull', 'maxArgMaxOrNullIf', 'countIf', 'countArray', 'countArrayIf', 'countArrayOrDefault', 'countArrayOrDefaultIf', 'countArrayOrNull', 'countArrayOrNullIf', 'countMap', 'countMapIf', 'countMapOrDefault', 'countMapOrDefaultIf', 'countMapOrNull', 'countMapOrNullIf', 'countState', 'countStateIf', 'countStateOrDefault', 'countStateOrDefaultIf', 'countStateOrNull', 'countStateOrNullIf', 'countMerge', 'countMergeIf', 'countMergeOrDefault', 'countMergeOrDefaultIf', 'countMergeOrNull', 'countMergeOrNullIf', 'countForEach', 'countForEachIf', 'countForEachOrDefault', 'countForEachOrDefaultIf', 'countForEachOrNull', 'countForEachOrNullIf', 'countOrDefault', 'countOrDefaultIf', 'countOrNull', 'countOrNullIf', 'countArgMin', 'countArgMinIf', 'countArgMinOrDefault', 'countArgMinOrDefaultIf', 'countArgMinOrNull', 'countArgMinOrNullIf', 'countArgMax', 'countArgMaxIf', 'countArgMaxOrDefault', 'countArgMaxOrDefaultIf', 'countArgMaxOrNull', 'countArgMaxOrNullIf', 'countDistinctIf', 'countDistinctArray', 'countDistinctArrayIf', 'countDistinctArrayOrDefault', 'countDistinctArrayOrDefaultIf', 'countDistinctArrayOrNull', 'countDistinctArrayOrNullIf', 'countDistinctMap', 'countDistinctMapIf', 'countDistinctMapOrDefault', 'countDistinctMapOrDefaultIf', 'countDistinctMapOrNull', 'countDistinctMapOrNullIf', 'countDistinctState', 'countDistinctStateIf', 'countDistinctStateOrDefault', 'countDistinctStateOrDefaultIf', 'countDistinctStateOrNull', 'countDistinctStateOrNullIf', 'countDistinctMerge', 'countDistinctMergeIf', 'countDistinctMergeOrDefault', 'countDistinctMergeOrDefaultIf', 'countDistinctMergeOrNull', 'countDistinctMergeOrNullIf', 'countDistinctForEach', 'countDistinctForEachIf', 'countDistinctForEachOrDefault', 'countDistinctForEachOrDefaultIf', 'countDistinctForEachOrNull', 'countDistinctForEachOrNullIf', 'countDistinctOrDefault', 'countDistinctOrDefaultIf', 'countDistinctOrNull', 'countDistinctOrNullIf', 'countDistinctArgMin', 'countDistinctArgMinIf', 'countDistinctArgMinOrDefault', 'countDistinctArgMinOrDefaultIf', 'countDistinctArgMinOrNull', 'countDistinctArgMinOrNullIf', 'countDistinctArgMax', 'countDistinctArgMaxIf', 'countDistinctArgMaxOrDefault', 'countDistinctArgMaxOrDefaultIf', 'countDistinctArgMaxOrNull', 'countDistinctArgMaxOrNullIf', 'medianIf', 'medianArray', 'medianArrayIf', 'medianArrayOrDefault', 'medianArrayOrDefaultIf', 'medianArrayOrNull', 'medianArrayOrNullIf', 'medianMap', 'medianMapIf', 'medianMapOrDefault', 'medianMapOrDefaultIf', 'medianMapOrNull', 'medianMapOrNullIf', 'medianState', 'medianStateIf', 'medianStateOrDefault', 'medianStateOrDefaultIf', 'medianStateOrNull', 'medianStateOrNullIf', 'medianMerge', 'medianMergeIf', 'medianMergeOrDefault', 'medianMergeOrDefaultIf', 'medianMergeOrNull', 'medianMergeOrNullIf', 'medianForEach', 'medianForEachIf', 'medianForEachOrDefault', 'medianForEachOrDefaultIf', 'medianForEachOrNull', 'medianForEachOrNullIf', 'medianOrDefault', 'medianOrDefaultIf', 'medianOrNull', 'medianOrNullIf', 'medianArgMin', 'medianArgMinIf', 'medianArgMinOrDefault', 'medianArgMinOrDefaultIf', 'medianArgMinOrNull', 'medianArgMinOrNullIf', 'medianArgMax', 'medianArgMaxIf', 'medianArgMaxOrDefault', 'medianArgMaxOrDefaultIf', 'medianArgMaxOrNull', 'medianArgMaxOrNullIf', 'count', 'countDistinct', 'min', 'max', 'sum', 'avg', 'avgMapState', 'avgMapMerge', 'avgMapMergeIf', 'any', 'anyIf', 'stddevPop', 'stddevPopIf', 'stddevSamp', 'stddevSampIf', 'varPop', 'varPopIf', 'varSamp', 'varSampIf', 'covarPop', 'covarPopIf', 'covarSamp', 'covarSampIf', 'corr', 'array_agg', 'groupArray', 'json_agg', 'string_agg', 'every', 'anyHeavy', 'anyHeavyIf', 'anyLast', 'anyLastIf', 'argMin', 'argMinIf', 'argMax', 'argMaxIf', 'argMinMerge', 'argMaxMerge', 'argMinState', 'argMaxState', 'sumForEachState', 'sumForEachMerge', 'avgWeighted', 'avgWeightedIf', 'topK', 'groupArrayIf', 'groupUniqArray', 'groupUniqArrayIf', 'groupUniqArrayArray', 'groupUniqArrayArrayIf', 'groupArrayInsertAt', 'groupArrayInsertAtIf', 'groupArrayMovingAvg', 'groupArrayMovingAvgIf', 'groupArrayMovingSum', 'groupArrayMovingSumIf', 'groupArraySample', 'groupArraySampleIf', 'groupBitAnd', 'groupBitAndIf', 'groupBitOr', 'groupBitOrIf', 'groupBitXor', 'groupBitXorIf', 'groupBitmap', 'groupBitmapIf', 'groupBitmapState', 'groupBitmapAnd', 'groupBitmapAndIf', 'groupBitmapAndState', 'groupBitmapOr', 'groupBitmapOrIf', 'groupBitmapOrState', 'groupBitmapXor', 'groupBitmapXorIf', 'sumWithOverflow', 'sumWithOverflowIf', 'deltaSum', 'deltaSumIf', 'deltaSumTimestamp', 'deltaSumTimestampIf', 'sumMapMerge', 'sumMapMergeIf', 'skewSamp', 'skewSampIf', 'skewPop', 'skewPopIf', 'kurtSamp', 'kurtSampIf', 'kurtPop', 'kurtPopIf', 'uniq', 'uniqIf', 'uniqExact', 'uniqExactState', 'uniqExactMerge', 'uniqExactIf', 'uniqCombined', 'uniqHLL12', 'uniqHLL12If', 'uniqTheta', 'uniqThetaIf', 'uniqMerge', 'uniqMergeIf', 'uniqMap', 'uniqMapMerge', 'uniqMapMergeIf', 'uniqState', 'uniqStateIf', 'uniqUpToMerge', 'median', 'medianExact', 'medianExactIf', 'medianExactLow', 'medianExactLowIf', 'medianExactHigh', 'medianExactHighIf', 'medianExactWeighted', 'medianExactWeightedIf', 'medianTiming', 'medianTimingIf', 'medianTimingWeighted', 'medianTimingWeightedIf', 'medianDeterministic', 'medianDeterministicIf', 'medianTDigest', 'medianTDigestIf', 'medianTDigestWeighted', 'medianTDigestWeightedIf', 'medianBFloat16', 'medianBFloat16If', 'percentile_cont', 'percentile_disc', 'quantile', 'quantileIf', 'quantiles', 'quantilesIf', 'quantilesState', 'quantilesStateIf', 'quantilesMerge', 'quantilesMergeIf', 'quantileExact', 'simpleLinearRegression', 'simpleLinearRegressionIf', 'contingency', 'contingencyIf', 'cramersV', 'cramersVIf', 'cramersVBiasCorrected', 'cramersVBiasCorrectedIf', 'theilsU', 'theilsUIf', 'maxIntersections', 'maxIntersectionsIf', 'maxIntersectionsPosition', 'maxIntersectionsPositionIf', 'windowFunnel', 'md5']
+ ['avgIf', 'avgArray', 'avgArrayIf', 'avgArrayOrDefault', 'avgArrayOrDefaultIf', 'avgArrayOrNull', 'avgArrayOrNullIf', 'avgMap', 'avgMapIf', 'avgMapOrDefault', 'avgMapOrDefaultIf', 'avgMapOrNull', 'avgMapOrNullIf', 'avgState', 'avgStateIf', 'avgStateOrDefault', 'avgStateOrDefaultIf', 'avgStateOrNull', 'avgStateOrNullIf', 'avgMerge', 'avgMergeIf', 'avgMergeOrDefault', 'avgMergeOrDefaultIf', 'avgMergeOrNull', 'avgMergeOrNullIf', 'avgForEach', 'avgForEachIf', 'avgForEachOrDefault', 'avgForEachOrDefaultIf', 'avgForEachOrNull', 'avgForEachOrNullIf', 'avgOrDefault', 'avgOrDefaultIf', 'avgOrNull', 'avgOrNullIf', 'avgArgMin', 'avgArgMinIf', 'avgArgMinOrDefault', 'avgArgMinOrDefaultIf', 'avgArgMinOrNull', 'avgArgMinOrNullIf', 'avgArgMax', 'avgArgMaxIf', 'avgArgMaxOrDefault', 'avgArgMaxOrDefaultIf', 'avgArgMaxOrNull', 'avgArgMaxOrNullIf', 'sumIf', 'sumArray', 'sumArrayIf', 'sumArrayOrDefault', 'sumArrayOrDefaultIf', 'sumArrayOrNull', 'sumArrayOrNullIf', 'sumMap', 'sumMapIf', 'sumMapOrDefault', 'sumMapOrDefaultIf', 'sumMapOrNull', 'sumMapOrNullIf', 'sumState', 'sumStateIf', 'sumStateOrDefault', 'sumStateOrDefaultIf', 'sumStateOrNull', 'sumStateOrNullIf', 'sumMerge', 'sumMergeIf', 'sumMergeOrDefault', 'sumMergeOrDefaultIf', 'sumMergeOrNull', 'sumMergeOrNullIf', 'sumForEach', 'sumForEachIf', 'sumForEachOrDefault', 'sumForEachOrDefaultIf', 'sumForEachOrNull', 'sumForEachOrNullIf', 'sumOrDefault', 'sumOrDefaultIf', 'sumOrNull', 'sumOrNullIf', 'sumArgMin', 'sumArgMinIf', 'sumArgMinOrDefault', 'sumArgMinOrDefaultIf', 'sumArgMinOrNull', 'sumArgMinOrNullIf', 'sumArgMax', 'sumArgMaxIf', 'sumArgMaxOrDefault', 'sumArgMaxOrDefaultIf', 'sumArgMaxOrNull', 'sumArgMaxOrNullIf', 'minIf', 'minArray', 'minArrayIf', 'minArrayOrDefault', 'minArrayOrDefaultIf', 'minArrayOrNull', 'minArrayOrNullIf', 'minMap', 'minMapIf', 'minMapOrDefault', 'minMapOrDefaultIf', 'minMapOrNull', 'minMapOrNullIf', 'minState', 'minStateIf', 'minStateOrDefault', 'minStateOrDefaultIf', 'minStateOrNull', 'minStateOrNullIf', 'minMerge', 'minMergeIf', 'minMergeOrDefault', 'minMergeOrDefaultIf', 'minMergeOrNull', 'minMergeOrNullIf', 'minForEach', 'minForEachIf', 'minForEachOrDefault', 'minForEachOrDefaultIf', 'minForEachOrNull', 'minForEachOrNullIf', 'minOrDefault', 'minOrDefaultIf', 'minOrNull', 'minOrNullIf', 'minArgMin', 'minArgMinIf', 'minArgMinOrDefault', 'minArgMinOrDefaultIf', 'minArgMinOrNull', 'minArgMinOrNullIf', 'minArgMax', 'minArgMaxIf', 'minArgMaxOrDefault', 'minArgMaxOrDefaultIf', 'minArgMaxOrNull', 'minArgMaxOrNullIf', 'maxIf', 'maxArray', 'maxArrayIf', 'maxArrayOrDefault', 'maxArrayOrDefaultIf', 'maxArrayOrNull', 'maxArrayOrNullIf', 'maxMap', 'maxMapIf', 'maxMapOrDefault', 'maxMapOrDefaultIf', 'maxMapOrNull', 'maxMapOrNullIf', 'maxState', 'maxStateIf', 'maxStateOrDefault', 'maxStateOrDefaultIf', 'maxStateOrNull', 'maxStateOrNullIf', 'maxMerge', 'maxMergeIf', 'maxMergeOrDefault', 'maxMergeOrDefaultIf', 'maxMergeOrNull', 'maxMergeOrNullIf', 'maxForEach', 'maxForEachIf', 'maxForEachOrDefault', 'maxForEachOrDefaultIf', 'maxForEachOrNull', 'maxForEachOrNullIf', 'maxOrDefault', 'maxOrDefaultIf', 'maxOrNull', 'maxOrNullIf', 'maxArgMin', 'maxArgMinIf', 'maxArgMinOrDefault', 'maxArgMinOrDefaultIf', 'maxArgMinOrNull', 'maxArgMinOrNullIf', 'maxArgMax', 'maxArgMaxIf', 'maxArgMaxOrDefault', 'maxArgMaxOrDefaultIf', 'maxArgMaxOrNull', 'maxArgMaxOrNullIf', 'countIf', 'countArray', 'countArrayIf', 'countArrayOrDefault', 'countArrayOrDefaultIf', 'countArrayOrNull', 'countArrayOrNullIf', 'countMap', 'countMapIf', 'countMapOrDefault', 'countMapOrDefaultIf', 'countMapOrNull', 'countMapOrNullIf', 'countState', 'countStateIf', 'countStateOrDefault', 'countStateOrDefaultIf', 'countStateOrNull', 'countStateOrNullIf', 'countMerge', 'countMergeIf', 'countMergeOrDefault', 'countMergeOrDefaultIf', 'countMergeOrNull', 'countMergeOrNullIf', 'countForEach', 'countForEachIf', 'countForEachOrDefault', 'countForEachOrDefaultIf', 'countForEachOrNull', 'countForEachOrNullIf', 'countOrDefault', 'countOrDefaultIf', 'countOrNull', 'countOrNullIf', 'countArgMin', 'countArgMinIf', 'countArgMinOrDefault', 'countArgMinOrDefaultIf', 'countArgMinOrNull', 'countArgMinOrNullIf', 'countArgMax', 'countArgMaxIf', 'countArgMaxOrDefault', 'countArgMaxOrDefaultIf', 'countArgMaxOrNull', 'countArgMaxOrNullIf', 'countDistinctIf', 'countDistinctArray', 'countDistinctArrayIf', 'countDistinctArrayOrDefault', 'countDistinctArrayOrDefaultIf', 'countDistinctArrayOrNull', 'countDistinctArrayOrNullIf', 'countDistinctMap', 'countDistinctMapIf', 'countDistinctMapOrDefault', 'countDistinctMapOrDefaultIf', 'countDistinctMapOrNull', 'countDistinctMapOrNullIf', 'countDistinctState', 'countDistinctStateIf', 'countDistinctStateOrDefault', 'countDistinctStateOrDefaultIf', 'countDistinctStateOrNull', 'countDistinctStateOrNullIf', 'countDistinctMerge', 'countDistinctMergeIf', 'countDistinctMergeOrDefault', 'countDistinctMergeOrDefaultIf', 'countDistinctMergeOrNull', 'countDistinctMergeOrNullIf', 'countDistinctForEach', 'countDistinctForEachIf', 'countDistinctForEachOrDefault', 'countDistinctForEachOrDefaultIf', 'countDistinctForEachOrNull', 'countDistinctForEachOrNullIf', 'countDistinctOrDefault', 'countDistinctOrDefaultIf', 'countDistinctOrNull', 'countDistinctOrNullIf', 'countDistinctArgMin', 'countDistinctArgMinIf', 'countDistinctArgMinOrDefault', 'countDistinctArgMinOrDefaultIf', 'countDistinctArgMinOrNull', 'countDistinctArgMinOrNullIf', 'countDistinctArgMax', 'countDistinctArgMaxIf', 'countDistinctArgMaxOrDefault', 'countDistinctArgMaxOrDefaultIf', 'countDistinctArgMaxOrNull', 'countDistinctArgMaxOrNullIf', 'medianIf', 'medianArray', 'medianArrayIf', 'medianArrayOrDefault', 'medianArrayOrDefaultIf', 'medianArrayOrNull', 'medianArrayOrNullIf', 'medianMap', 'medianMapIf', 'medianMapOrDefault', 'medianMapOrDefaultIf', 'medianMapOrNull', 'medianMapOrNullIf', 'medianState', 'medianStateIf', 'medianStateOrDefault', 'medianStateOrDefaultIf', 'medianStateOrNull', 'medianStateOrNullIf', 'medianMerge', 'medianMergeIf', 'medianMergeOrDefault', 'medianMergeOrDefaultIf', 'medianMergeOrNull', 'medianMergeOrNullIf', 'medianForEach', 'medianForEachIf', 'medianForEachOrDefault', 'medianForEachOrDefaultIf', 'medianForEachOrNull', 'medianForEachOrNullIf', 'medianOrDefault', 'medianOrDefaultIf', 'medianOrNull', 'medianOrNullIf', 'medianArgMin', 'medianArgMinIf', 'medianArgMinOrDefault', 'medianArgMinOrDefaultIf', 'medianArgMinOrNull', 'medianArgMinOrNullIf', 'medianArgMax', 'medianArgMaxIf', 'medianArgMaxOrDefault', 'medianArgMaxOrDefaultIf', 'medianArgMaxOrNull', 'medianArgMaxOrNullIf', 'count', 'countDistinct', 'min', 'max', 'sum', 'avg', 'avgMapState', 'avgMapMerge', 'avgMapMergeIf', 'any', 'anyIf', 'stddevPop', 'stddevPopIf', 'stddevSamp', 'stddevSampIf', 'varPop', 'varPopIf', 'varSamp', 'varSampIf', 'covarPop', 'covarPopIf', 'covarSamp', 'covarSampIf', 'corr', 'array_agg', 'groupArray', 'json_agg', 'string_agg', 'every', 'anyHeavy', 'anyHeavyIf', 'anyLast', 'anyLastIf', 'argMin', 'argMinIf', 'argMax', 'argMaxIf', 'argMinMerge', 'argMaxMerge', 'argMinState', 'argMaxState', 'sumForEachState', 'sumForEachMerge', 'avgWeighted', 'avgWeightedIf', 'topK', 'groupArrayIf', 'groupUniqArray', 'groupUniqArrayIf', 'groupUniqArrayArray', 'groupUniqArrayArrayIf', 'groupArrayInsertAt', 'groupArrayInsertAtIf', 'groupArrayMovingAvg', 'groupArrayMovingAvgIf', 'groupArrayMovingSum', 'groupArrayMovingSumIf', 'groupArraySample', 'groupArraySampleIf', 'groupBitAnd', 'groupBitAndIf', 'groupBitOr', 'groupBitOrIf', 'groupBitXor', 'groupBitXorIf', 'groupBitmap', 'groupBitmapIf', 'groupBitmapState', 'groupBitmapAnd', 'groupBitmapAndIf', 'groupBitmapAndState', 'groupBitmapOr', 'groupBitmapOrIf', 'groupBitmapOrState', 'groupBitmapXor', 'groupBitmapXorIf', 'sumWithOverflow', 'sumWithOverflowIf', 'deltaSum', 'deltaSumIf', 'deltaSumTimestamp', 'deltaSumTimestampIf', 'sumMapMerge', 'sumMapMergeIf', 'skewSamp', 'skewSampIf', 'skewPop', 'skewPopIf', 'kurtSamp', 'kurtSampIf', 'kurtPop', 'kurtPopIf', 'uniq', 'uniqIf', 'uniqExact', 'uniqExactState', 'uniqExactMerge', 'uniqExactIf', 'uniqCombined', 'uniqCombined64', 'uniqHLL12', 'uniqHLL12If', 'uniqTheta', 'uniqThetaIf', 'uniqMerge', 'uniqMergeIf', 'uniqMap', 'uniqMapMerge', 'uniqMapMergeIf', 'uniqState', 'uniqStateIf', 'uniqUpToMerge', 'median', 'medianExact', 'medianExactIf', 'medianExactLow', 'medianExactLowIf', 'medianExactHigh', 'medianExactHighIf', 'medianExactWeighted', 'medianExactWeightedIf', 'medianTiming', 'medianTimingIf', 'medianTimingWeighted', 'medianTimingWeightedIf', 'medianDeterministic', 'medianDeterministicIf', 'medianTDigest', 'medianTDigestIf', 'medianTDigestWeighted', 'medianTDigestWeightedIf', 'medianBFloat16', 'medianBFloat16If', 'percentile_cont', 'percentile_disc', 'quantile', 'quantileIf', 'quantiles', 'quantilesIf', 'quantilesState', 'quantilesStateIf', 'quantilesMerge', 'quantilesMergeIf', 'quantileExact', 'simpleLinearRegression', 'simpleLinearRegressionIf', 'contingency', 'contingencyIf', 'cramersV', 'cramersVIf', 'cramersVBiasCorrected', 'cramersVBiasCorrectedIf', 'theilsU', 'theilsUIf', 'maxIntersections', 'maxIntersectionsIf', 'maxIntersectionsPosition', 'maxIntersectionsPositionIf', 'windowFunnel', 'md5']
```
And lastly these are some HogQL specific functions:
diff --git a/products/metrics/backend/facade/api.py b/products/metrics/backend/facade/api.py
index 9a45e9c394ae..2f843d805037 100644
--- a/products/metrics/backend/facade/api.py
+++ b/products/metrics/backend/facade/api.py
@@ -354,14 +354,14 @@ def list_metric_attribute_keys(
date_to: dt.datetime | None = None,
limit: int = 100,
) -> list[dict[str, Any]]:
- """List attribute keys by distinct series count, from highest to lowest.
+ """List attribute keys by distinct value count, from highest to lowest.
When a metric name is provided, only series that emitted that metric in the
recent window supply choices. Datapoint and resource attributes are merged
into one list (filters run with scope 'auto', so the split doesn't matter
to callers); `service_name` is always surfaced when it matches the search.
The window defaults to the last 7 days. Returns `{"name": str,
- "series_count": int}` dicts. Raises `ValueError` for an out-of-range limit
+ "value_count": int}` dicts. Raises `ValueError` for an out-of-range limit
or an inverted window.
"""
runner = MetricAttributeKeysQueryRunner(
diff --git a/products/metrics/backend/metric_attributes_query_runner.py b/products/metrics/backend/metric_attributes_query_runner.py
index 770270817dc2..2d71e0f3d4ef 100644
--- a/products/metrics/backend/metric_attributes_query_runner.py
+++ b/products/metrics/backend/metric_attributes_query_runner.py
@@ -1,6 +1,6 @@
"""Attribute key/value autocomplete for the metrics filter bar.
-Keys count distinct series from recent metadata, without reading raw samples.
+Keys count distinct attribute values from recent metadata, without reading raw samples.
Values use the `metric_attributes` aggregate table.
Both queries merge metric attributes and resource attributes.
"""
@@ -56,7 +56,7 @@ def _validate_limit(limit: int) -> int:
class MetricAttributeKeysQueryRunner:
- """Attribute keys ordered by distinct recent series count."""
+ """Attribute keys ordered by distinct value count from recent series."""
def __init__(
self,
@@ -82,14 +82,17 @@ class MetricAttributeKeysQueryRunner:
arrayJoin(arrayDistinct(arrayConcat(
mapKeys(attributes), mapKeys(resource_attributes), ['service_name']
))) AS attribute_key,
- uniqExact(series_fingerprint) AS series_count
+ uniqCombined64(if(attribute_key IN ('service_name', 'service.name'), service_name,
+ if(arrayElement(resource_attributes, attribute_key) != '',
+ arrayElement(resource_attributes, attribute_key),
+ arrayElement(attributes, attribute_key)))) AS value_count
FROM posthog.metric_series
WHERE last_seen >= {date_from}
AND {metric_name_filter}
AND (attribute_key ILIKE {search_pattern}
OR (attribute_key = 'service_name' AND 'service.name' ILIKE {search_pattern}))
GROUP BY attribute_key
- ORDER BY series_count DESC, attribute_key ASC
+ ORDER BY value_count DESC, attribute_key ASC
LIMIT {limit}
""",
placeholders={
@@ -117,10 +120,10 @@ class MetricAttributeKeysQueryRunner:
settings=_QUERY_SETTINGS,
)
- results = [{"name": row[0], "series_count": int(row[1])} for row in response.results]
+ results = [{"name": row[0], "value_count": int(row[1])} for row in response.results]
search_lower = self.search.lower()
if not results and (search_lower in "service_name" or search_lower in "service.name"):
- results.append({"name": "service_name", "series_count": 0})
+ results.append({"name": "service_name", "value_count": 0})
return results
diff --git a/products/metrics/backend/presentation/api.py b/products/metrics/backend/presentation/api.py
index e03eb03ff70b..037fae2c5e38 100644
--- a/products/metrics/backend/presentation/api.py
+++ b/products/metrics/backend/presentation/api.py
@@ -581,15 +581,15 @@ class _MetricAttributeKeySerializer(serializers.Serializer):
name = serializers.CharField(
help_text="Attribute key as it appears on the team's metrics (e.g. 'env', 'k8s.pod.name')."
)
- series_count = serializers.IntegerField(
- help_text="Number of distinct recent series with this attribute, based on series metadata."
+ value_count = serializers.IntegerField(
+ help_text="Number of distinct values for this attribute in recent series metadata."
)
class _MetricAttributeKeysResponseSerializer(serializers.Serializer):
results = _MetricAttributeKeySerializer(
many=True,
- help_text="Distinct attribute keys (datapoint and resource attributes merged), ordered by series count descending.",
+ help_text="Distinct attribute keys (datapoint and resource attributes merged), ordered by distinct value count descending.",
)
count = serializers.IntegerField(help_text="Number of keys returned.")
diff --git a/products/metrics/backend/tests/test_metric_attributes.py b/products/metrics/backend/tests/test_metric_attributes.py
index 6fef94918ceb..2b1402a9d757 100644
--- a/products/metrics/backend/tests/test_metric_attributes.py
+++ b/products/metrics/backend/tests/test_metric_attributes.py
@@ -53,11 +53,11 @@ class TestMetricAttributesAPI(ClickhouseTestMixin, APIBaseTest):
assert response.status_code == status.HTTP_200_OK, response.json()
body = response.json()
assert body["results"] == [
- {"name": "service_name", "series_count": 3},
- {"name": "env", "series_count": 2},
- {"name": "k8s.pod.name", "series_count": 1},
- {"name": "region", "series_count": 1},
- {"name": "stale_key", "series_count": 1},
+ {"name": "env", "value_count": 2},
+ {"name": "service_name", "value_count": 2},
+ {"name": "k8s.pod.name", "value_count": 1},
+ {"name": "region", "value_count": 1},
+ {"name": "stale_key", "value_count": 1},
]
assert body["count"] == 5
@@ -66,7 +66,7 @@ class TestMetricAttributesAPI(ClickhouseTestMixin, APIBaseTest):
("substring_of_attribute_key", "env", ["env"]),
("substring_of_synthetic_service_name", "serv", ["service_name"]),
("dotted_service_name", "service.name", ["service_name"]),
- ("series_count_order", "e", ["service_name", "env", "k8s.pod.name", "region", "stale_key"]),
+ ("value_count_order", "e", ["env", "service_name", "k8s.pod.name", "region", "stale_key"]),
]
)
def test_attributes_search_filters_keys(self, _name: str, search: str, expected: list[str]) -> None:
@@ -85,22 +85,27 @@ class TestMetricAttributesAPI(ClickhouseTestMixin, APIBaseTest):
)
assert response.status_code == status.HTTP_200_OK
assert response.json()["results"] == [
- {"name": "env", "series_count": 2},
- {"name": "service_name", "series_count": 2},
- {"name": "k8s.pod.name", "series_count": 1},
- {"name": "region", "series_count": 1},
+ {"name": "env", "value_count": 2},
+ {"name": "service_name", "value_count": 2},
+ {"name": "k8s.pod.name", "value_count": 1},
+ {"name": "region", "value_count": 1},
]
def test_attributes_metric_name_limits_keys_to_that_metric(self):
response = self._get("attributes", {"metricName": "http_requests"})
assert response.status_code == status.HTTP_200_OK, response.json()
assert response.json()["results"] == [
- {"name": "env", "series_count": 2},
- {"name": "service_name", "series_count": 2},
- {"name": "k8s.pod.name", "series_count": 1},
- {"name": "region", "series_count": 1},
+ {"name": "env", "value_count": 2},
+ {"name": "service_name", "value_count": 2},
+ {"name": "k8s.pod.name", "value_count": 1},
+ {"name": "region", "value_count": 1},
]
+ def test_attributes_without_recent_series_return_zero_service_values(self):
+ response = self._get("attributes", {"metricName": "missing_metric"})
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ assert response.json()["results"] == [{"name": "service_name", "value_count": 0}]
+
def test_attribute_values_returns_values_with_aggregated_counts(self):
response = self._get("attribute_values", {"key": "env"})
assert response.status_code == status.HTTP_200_OK
@@ -132,3 +137,37 @@ class TestMetricAttributesAPI(ClickhouseTestMixin, APIBaseTest):
def test_bad_params_are_400(self, _name: str, action: str, params: dict) -> None:
response = self._get(action, params)
assert response.status_code == status.HTTP_400_BAD_REQUEST
+
+
+class TestMetricAttributeDistinctValuesAPI(ClickhouseTestMixin, APIBaseTest):
+ def test_attributes_count_distinct_values_with_grouping_scope_precedence(self):
+ truncate_metrics_tables()
+ now = timezone.now().replace(second=0, microsecond=0)
+ for index, (labels, resource_labels) in enumerate(
+ [
+ ({"env": "prod", "region": "ignored-a"}, {"region": "us"}),
+ ({"env": "prod", "region": "ignored-b"}, {"region": "us"}),
+ ({"env": "prod", "region": "eu"}, {"region": ""}),
+ ({"env": "prod", "region": ""}, {}),
+ ]
+ ):
+ seed_metric(
+ team_id=self.team.id,
+ metric_name="distinct_values",
+ service_name="checkout",
+ points=[(now - dt.timedelta(minutes=2), 1.0)],
+ labels={**labels, "instance": str(index)},
+ resource_labels=resource_labels,
+ )
+
+ response = self.client.get(
+ f"/api/projects/{self.team.id}/metrics/attributes/", {"metricName": "distinct_values"}
+ )
+
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ assert response.json()["results"] == [
+ {"name": "instance", "value_count": 4},
+ {"name": "region", "value_count": 3},
+ {"name": "env", "value_count": 1},
+ {"name": "service_name", "value_count": 1},
+ ]
diff --git a/products/metrics/frontend/components/MetricsGroupByButton.stories.tsx b/products/metrics/frontend/components/MetricsGroupByButton.stories.tsx
index 06b058399a46..030a09177e6d 100644
--- a/products/metrics/frontend/components/MetricsGroupByButton.stories.tsx
+++ b/products/metrics/frontend/components/MetricsGroupByButton.stories.tsx
@@ -15,10 +15,10 @@ const meta: Meta<typeof MetricsGroupByButton> = {
'/api/projects/:team_id/metrics/values/': { results: [] },
'/api/projects/:team_id/metrics/attributes/': {
results: [
- { name: 'service_name', series_count: 12000 },
- { name: 'environment', series_count: 8000 },
- { name: 'k8s.pod.name', series_count: 350 },
- { name: 'resource.attribute.with.a.long.name', series_count: 25 },
+ { name: 'k8s.pod.name', value_count: 350 },
+ { name: 'service_name', value_count: 20 },
+ { name: 'environment', value_count: 2 },
+ { name: 'resource.attribute.with.a.long.name', value_count: 1 },
],
count: 4,
},
@@ -49,7 +49,7 @@ export const Default: Story = {
trigger.click()
await waitFor(() => {
if (!document.querySelector('.tabular-nums')) {
- throw new Error('Series counts are not visible')
+ throw new Error('Distinct value counts are not visible')
}
})
},
diff --git a/products/metrics/frontend/components/MetricsGroupByButton.tsx b/products/metrics/frontend/components/MetricsGroupByButton.tsx
index 35499344edc9..5691950f9d3a 100644
--- a/products/metrics/frontend/components/MetricsGroupByButton.tsx
+++ b/products/metrics/frontend/components/MetricsGroupByButton.tsx
@@ -48,8 +48,8 @@ export function MetricsGroupByButton({
labelComponent: (
<span className="flex items-center justify-between gap-2">
<span className="truncate">{option.label}</span>
- <Tooltip title="Number of series with this attribute">
- <span className="text-muted tabular-nums shrink-0">{option.seriesCount}</span>
+ <Tooltip title="Number of distinct values">
+ <span className="text-muted tabular-nums shrink-0">{option.valueCount}</span>
</Tooltip>
</span>
),
diff --git a/products/metrics/frontend/components/MetricsViewer.test.tsx b/products/metrics/frontend/components/MetricsViewer.test.tsx
index be889179ec22..d1fd752bc1ef 100644
--- a/products/metrics/frontend/components/MetricsViewer.test.tsx
+++ b/products/metrics/frontend/components/MetricsViewer.test.tsx
@@ -71,11 +71,11 @@ describe('MetricsViewer', () => {
logic?.unmount()
})
- it('shows series counts in the group-by dropdown and selects the attribute key', async () => {
+ it('shows distinct value counts in the group-by dropdown and selects the attribute key', async () => {
jest.mocked(metricsAttributesRetrieve).mockResolvedValue({
results: [
- { name: 'service_name', series_count: 20 },
- { name: 'env', series_count: 2 },
+ { name: 'service_name', value_count: 20 },
+ { name: 'env', value_count: 2 },
],
count: 2,
})
@@ -86,7 +86,7 @@ describe('MetricsViewer', () => {
const envOption = screen.getByText('env')
expect(serviceOption.compareDocumentPosition(envOption) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
await userEvent.hover(screen.getByText('20'))
- expect(await screen.findByText('Number of series with this attribute')).toBeInTheDocument()
+ expect(await screen.findByText('Number of distinct values')).toBeInTheDocument()
fireEvent.change(screen.getByPlaceholderText('Group by attribute…'), { target: { value: 'e' } })
expect(serviceOption.compareDocumentPosition(envOption) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
fireEvent.click(envOption)
diff --git a/products/metrics/frontend/components/metricsViewerLogic.test.ts b/products/metrics/frontend/components/metricsViewerLogic.test.ts
index 71c53770a23c..33914402c0bc 100644
--- a/products/metrics/frontend/components/metricsViewerLogic.test.ts
+++ b/products/metrics/frontend/components/metricsViewerLogic.test.ts
@@ -667,8 +667,8 @@ describe('metricsViewerLogic', () => {
it('group-by search keeps the series counts and order from the selected metric API response', async () => {
jest.mocked(metricsAttributesRetrieve).mockResolvedValue({
results: [
- { name: 'service_name', series_count: 20 },
- { name: 'env', series_count: 2 },
+ { name: 'service_name', value_count: 20 },
+ { name: 'env', value_count: 2 },
],
count: 2,
})
@@ -681,8 +681,8 @@ describe('metricsViewerLogic', () => {
expect.objectContaining({ search: 'e', metricName: 'requests_total' })
)
expect(logic.values.attributeKeyOptions).toEqual([
- { key: 'service_name', label: 'service_name', seriesCount: 20 },
- { key: 'env', label: 'env', seriesCount: 2 },
+ { key: 'service_name', label: 'service_name', valueCount: 20 },
+ { key: 'env', label: 'env', valueCount: 2 },
])
})
diff --git a/products/metrics/frontend/components/metricsViewerLogic.tsx b/products/metrics/frontend/components/metricsViewerLogic.tsx
index 566dad42129a..3b0704bbbd9b 100644
--- a/products/metrics/frontend/components/metricsViewerLogic.tsx
+++ b/products/metrics/frontend/components/metricsViewerLogic.tsx
@@ -352,7 +352,7 @@ export interface metricsViewerLogicValues {
attributeKeyOptions: {
key: string
label: string
- seriesCount: number
+ valueCount: number
}[]
attributeKeyOptionsLoading: boolean
chartSeries: MetricsChartSeries[]
@@ -502,14 +502,14 @@ export interface metricsViewerLogicActions {
attributeKeyOptions: {
key: string
label: string
- seriesCount: number
+ valueCount: number
}[],
payload?: any
) => {
attributeKeyOptions: {
key: string
label: string
- seriesCount: number
+ valueCount: number
}[]
payload?: any
}
@@ -1110,7 +1110,7 @@ export const metricsViewerLogic = kea<metricsViewerLogicType>([
// viewer window so choices match the data the clause can actually group; debounce to
// match the chart fetch cadence.
attributeKeyOptions: [
- [] as { key: string; label: string; seriesCount: number }[],
+ [] as { key: string; label: string; valueCount: number }[],
{
loadAttributeKeyOptions: async (_, breakpoint) => {
if (!canViewMetrics()) {
@@ -1130,7 +1130,7 @@ export const metricsViewerLogic = kea<metricsViewerLogicType>([
return response.results.map((result) => ({
key: result.name,
label: result.name,
- seriesCount: result.series_count,
+ valueCount: result.value_count,
}))
},
},
diff --git a/products/metrics/frontend/generated/api.schemas.ts b/products/metrics/frontend/generated/api.schemas.ts
index bea8f808894a..924c18e49ac1 100644
--- a/products/metrics/frontend/generated/api.schemas.ts
+++ b/products/metrics/frontend/generated/api.schemas.ts
@@ -40,12 +40,12 @@ export interface _MetricAttributeValuesResponseApi {
export interface _MetricAttributeKeyApi {
/** Attribute key as it appears on the team's metrics (e.g. 'env', 'k8s.pod.name'). */
name: string
- /** Number of distinct recent series with this attribute, based on series metadata. */
- series_count: number
+ /** Number of distinct values for this attribute in recent series metadata. */
+ value_count: number
}
export interface _MetricAttributeKeysResponseApi {
- /** Distinct attribute keys (datapoint and resource attributes merged), ordered by series count descending. */
+ /** Distinct attribute keys (datapoint and resource attributes merged), ordered by distinct value count descending. */
results: _MetricAttributeKeyApi[]
/** Number of keys returned. */
count: number
diff --git a/services/hogql-language-service/internal/completion/functions.go b/services/hogql-language-service/internal/completion/functions.go
index 7bc94dca248d..bf9f631d8191 100644
--- a/services/hogql-language-service/internal/completion/functions.go
+++ b/services/hogql-language-service/internal/completion/functions.go
@@ -61,7 +61,7 @@ toIPv4OrDefault toIPv4OrNull toIPv4OrZero toIPv6 toIPv6OrDefault toIPv6OrNull to
toJSONString toLastDayOfMonth toLastDayOfWeek toMinute toModifiedJulianDay toMonday toMonth toNullable toNullableString toQuarter toSecond toStartOfDay toStartOfFifteenMinutes toStartOfFiveMinutes toStartOfHour toStartOfISOYear toStartOfInterval toStartOfMinute toStartOfMonth toStartOfQuarter
toStartOfSecond toStartOfTenMinutes toStartOfWeek toStartOfYear toString toTime toTimeZone toTypeName toUUID toUUIDOrDefault toUnixTimestamp toUnixTimestamp64Milli toValidUTF8 toWeek toYYYYMM toYYYYMMDD toYYYYMMDDhhmmss toYear toYearWeek to_char
to_date to_timestamp today tokens topK topLevelDomain transform translate translateUTF8 trim trimLeft trimRight trunc tryBase58Decode tryBase64Decode tumble tumbleEnd tumbleStart tuple tupleDivide
-tupleDivideByNumber tupleElement tupleHammingDistance tupleMinus tupleMultiply tupleMultiplyByNumber tupleNegate tuplePlus tupleToNameValuePairs unhex uniq uniqCombined uniqExact uniqExactIf uniqExactMerge uniqExactState uniqHLL12 uniqHLL12If uniqIf uniqMap
-uniqMapMerge uniqMapMergeIf uniqMerge uniqMergeIf uniqState uniqStateIf uniqTheta uniqThetaIf uniqUpToMerge uniqueSurveySubmissionsFilter untuple upper upperUTF8 varPop varPopIf varSamp varSampIf width_bucket windowFunnel xor
-yesterday
+tupleDivideByNumber tupleElement tupleHammingDistance tupleMinus tupleMultiply tupleMultiplyByNumber tupleNegate tuplePlus tupleToNameValuePairs unhex uniq uniqCombined uniqCombined64 uniqExact uniqExactIf uniqExactMerge uniqExactState uniqHLL12 uniqHLL12If uniqIf
+uniqMap uniqMapMerge uniqMapMergeIf uniqMerge uniqMergeIf uniqState uniqStateIf uniqTheta uniqThetaIf uniqUpToMerge uniqueSurveySubmissionsFilter untuple upper upperUTF8 varPop varPopIf varSamp varSampIf width_bucket windowFunnel
+xor yesterday
`)
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index cda33409d2f5..53abfb21fb4a 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -97788,12 +97788,12 @@ export namespace Schemas {
export interface _MetricAttributeKey {
/** Attribute key as it appears on the team's metrics (e.g. 'env', 'k8s.pod.name'). */
name: string;
- /** Number of distinct recent series with this attribute, based on series metadata. */
- series_count: number;
+ /** Number of distinct values for this attribute in recent series metadata. */
+ value_count: number;
}
export interface _MetricAttributeKeysResponse {
- /** Distinct attribute keys (datapoint and resource attributes merged), ordered by series count descending. */
+ /** Distinct attribute keys (datapoint and resource attributes merged), ordered by distinct value count descending. */
results: _MetricAttributeKey[];
/** Number of keys returned. */
count: number;