Get list of ip addresses

Hi all,

I have loki receiving logs like

{"client_ip":"141.147.27.251","duration":"41.000000ms","level":"INFO","method":"POST","path":"/api/v1/play"}

I would like to create a query that can list the IP addresses hitting that endpoint /api/v1/play

Is there a way to create such list of IP addresses? I spent a good amount of time googling but could not find a way to do so.
Thanks in advance for any help.

What kind of output are you looking for?

Easiest query would be something like sum by (client_ip) (count_over_time({SELECTOR} | json [$__interval])), which will generate a time series metrics aggregated by client_ip.

1 Like

Hi,

Thank you. It did what I was expecting!

At the end just needed to do the following in my case

sum by (client_ip) (count_over_time({app="my-app", environment="production"} | json | path="/api/v1/play" [$__interval]))