I am using Grafana together with Grafana Loki to monitor a service through its access logs. I have been able to extract the number of requests over a given time range, as well as the top 10 paths and requests to specific URLs.
What I would also like to count is the number of unique users. My possibilities are very limited here, so I decided to count the number of unique IPs as an approximation. But when I run the following query on larger time frames (7 days in my case), it fails due to the 500 series limit.
count(count_over_time({job="data-collections-explorer", code="200"} | regexp `^(?:[^ ]+ )?(?P<ip>[^ ]+) - -.*` | keep ip [$__range]))
I understand why the query runs into this issue (more than 500 unique IPs resulting in more than 500 time queries), but I was hoping there are alternative ways to retrieve the metric I am looking for. In my case, I don’t even need the time series that count_over_time creates, I just want the absolute number of unique values over the given range. Is there any way of doing something like this in LogQL?
I assume using the tranformations in the Grafana Dashboards is not a good approach, as it would run into the line limit. (1000 log lines, which is the limit, reaches only 2 days into the past in my case)
(Side note: I already have set up recording rules for unique IPs in the last 24 hours, I am just looking for ways to make the above query work. That would allow me to also record the number of unique IPs per 7 days)
Thank you for taking the time to read my post