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 ( ) 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.