What's new from Grafana Labs
Estimate distinct log values with approx_count_distinct
Estimate how many distinct values appear in your logs when an exact count would create too many series.
count by (<field>) returns one series for every distinct value. For a field such as a user ID, IP address, or session token, that series count can hit Loki’s maximum series limit or time out the query. approx_count_distinct estimates the number of distinct values of a label or extracted field and returns one series per group.
approx_count_distinct(
user_id,
{job="webapp"} | json [1d]
)approx_count_distinct(
ip_address,
{job="api"} | json [1d]
) by (version)Related What's new posts