Adding a LOKI report in Grafana counting number of http_user_agents from NGINX logs

To add a Loki report in Grafana, as for example having a count of the different http_user_agents that have logged in, you can use the following query:

SHELL

You select the source (Loki) and then use the {namespace=”ingress-nginx”,stream=”stdout”} to get the log files from Nginx.

Then you can filter by two conditions:

  1. the instance login
SHELL

and

  1. use the regular expression to only select the GET / calls
SHELL

Then you can use the pattern parser for the log file in order to get the label

SHELL

<_> is used if we are not interested in getting the field, so everything after http_agent is not analyzed in this case.

Finally use the

SHELL

to get the data (note that you also need to use the rate with the [$__interval])