# \[Loki\] LogQL - getting uniqe values from logs and count them

**URL:** <https://community.grafana.com/t/loki-logql-getting-uniqe-values-from-logs-and-count-them/88516>\
**Category:** Alerting\
**Tags:** helm, alerting, templating\
**Created:** [May 29, 2023, 9:35am UTC](https://community.grafana.com/t/loki-logql-getting-uniqe-values-from-logs-and-count-them/88516 "2023-05-29T09:35:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonshkilevich](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@simonshkilevich](https://community.grafana.com/u/simonshkilevich)\
**Post date:** [May 29, 2023, 9:35am UTC](https://community.grafana.com/t/loki-logql-getting-uniqe-values-from-logs-and-count-them/88516/1 "2023-05-29T09:35:16Z")

</div>

My stdout of logs looks something like this - all string format:

```auto
[customer1-name] - log line etc etc etc
[customer2-name] - log line etc etc etc
[customer3-name] - log line etc etc etc
[customer4-name] - log line etc etc etc

```

I want to create a simple dashboard that shows top 5 active customers based on filtering these log lines (I know its not 100% accurate but this is a metric I’m ok with, for now - the more log lines [customer-x] has the more he is active in the system)  
I am able to filter it using this regex:

```auto
{app="platform"} |~ `\[[a-zA-Z0-9-]+\]`

```

after a long time playing with it I probably can get count but missing one step of the puzzle - to show the customer name:

```auto
sum by (customer) (count_over_time({app="platform"} | regexp "customer=(?P<customer>\\[[a-zA-Z0-9-]+\\])"[5m])) 

```

returns me this:

 ![grafana1](https://us1.discourse-cdn.com/grafana/original/3X/1/3/1359943e149888203c729ed5ae165fcf11dae273.png)

what am I missing here?
