I have an apache log and I want to know which urls are requested most often. So I already have the following
{filename="/var/log/apache2/other_vhosts_access.log"} | regexp `(?P<domain>[^:]+).* "(?P<method>[A-Z]+) (?P<url>(/[^/? ]+){0,2}).*`
which is working fine (the labels have the right values)
I now want the equivilant of the SQL Query select count(*) from ... group by url, domain, method;
I tried the following:
count by(domain, url, method) (rate({filename="/var/log/apache2/other_vhosts_access.log"} | regexp `(?P<domain>[^:]+).* "(?P<method>[A-Z]+) (?P<url>(/[^/? ]+){0,2}).*` [$__range]))
but this does not give me a single value per label tupel, but with
count by(domain, url, method) ({filename="/var/log/apache2/other_vhosts_access.log"} | regexp `(?P<domain>[^:]+).* "(?P<method>[A-Z]+) (?P<url>(/[^/? ]+){0,2}).*`)
I get the error: parse error at line 1, col 155: syntax error: unexpected )