Visualizations: Unique Count is Inaccurate

Hello,

As I been exploring the use of ES|QL , I found inconsistencies with metric visualizations using unique count. I have a dataset with 6,929 unique host.name values and for the sake of this it will only show up as 6,929 documents. So I did every metric visualization and was surprised to find the difference in values:

This is crazy!

Hi @erikg

The cardinality aggregation, the one that powers this feature in ES provides not an exact count of values.
More on this can be checked in this page: Cardinality aggregation | Elasticsearch Guide [8.17] | Elastic

I suspect that this is something that is affecting your visualizations here.

Hey @Marco_Liberati ,
thanks, I been using Unique count for a while and didn't know it was an approximate. This is very shocking as we have used unique count in Lens all throughout our dashboards. Depending on the level of cardinality, it seems we are providing inaccurate numbers.

Can we add precision_threshold to our Lens?

That is no possible with Lens charts: [Lens] Can't create a Lens visualization that produces accurate count(distinct) on field values · Issue #179934 · elastic/kibana · GitHub

The ES|QL has an enhancement request for this kind of things, which will enable also to build visualizations with it.

1 Like