Apache Server Monitoring with Promtail and Loki

Hi Together,

I am new to Grafana and have only used CheckMK for monitoring so far.

I would like to explore monitoring in more depth. Currently, I log all my hosts to an access.log file in JSON format.

The log keys are as follows:

{
“time”: “2025-01-24T06:52:53.740Z”,
“process”: “18567”,
“remoteIP”: “”,
“host”: “”,
“request”: “/ocs/v2.php/cloud/user”,
“query”: “?format=json”,
“method”: “GET”,
“status”: “200”,
“bytes”: “221”,
“userAgent”: “Mozilla/5.0 (Linux) mirall/5.3.1 (ownCloud, manjaro-6.12.4-1-MANJARO ClientArchitecture: x86_64 OsArchitecture: x86_64)”,
“referer”: “-”
}

How can I visualize this in Grafana and calculate a sum by remoteIP to count the number of accesses to the proxy per IP address? Additionally, how can I visualize data usage and similar metrics?

Many Greetings :smiley:

Assuming you already have your logs in Loki and they are in JSON format in a single line, it would be something like this (not tested):

sum by (remoteIP) (count_over_time({<LABEL_SELECTOR>} | json [$__auto]))

Hi @tonyswumac

this problem i have solved :smiley: 1h hour before the only thing i must do was reading the doku and understand the LogQL thing :smiley:

I have a new problem but i think i will also fix this :smiley:

Thank you for your help :smiley: