Import page generation time with real-time logging

Hi all,

I try to set a custom regex for real time log import while piping through Apache, but doesn’t matter what I try, I get a syntax error from Apache, or Invalid line detected (line did not match) from Matomo debug output.
Basically I just want to add the page generation time to the default vhost_combined LogFormat.

Debian 11.4, running Apache 2.4.54 with Python 3.9. Matomo version ist 4.11.0.

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %D" matomo
CustomLog /var/log/matomo/matomo.log matomo
CustomLog "||/usr/bin/python3.9 /var/www/web1/htdocs/xxx/matomo/misc/log-analytics/ --url=https://xxx --enable-reverse-dns --enable-static --enable-bots --enable-http-errors --enable-http-redirects --recorders=4 --recorder-max-payload-size=1 --log-format-regex='(?P<host>[\-\.\w]*)(?::\d+)?\s+(?P<ip>[\w*.:-]+)\s+\S+\s+(?P<userid>\S+)\s+\[(?P<date>.*?)\s+(?P<timezone>.*?)\]\s+\"(?P<method>\S+)\s+(?P<path>.*?)\s+\S+\"\s+(?P<status>\d+)\s+(?P<length>\S+)\s+\"(?P<referrer>.*?)\"\s+\"(?P<user_agent>.*?)\"\s+(?P<generation_time_micro>\d.+)' --output=/var/log/matomo/matomo_debug.log --debug --debug -" matomo

When I use the default regex with escaped " and add the generation_time_micro part (?P<host>[\w\-\.]*)(?::\d+)?\s+(?P<ip>[\w*.:-]+)\s+\S+\s+(?P<userid>\S+)\s+\[(?P<date>.*?)\s+(?P<timezone>.*?)\]\s+\"(?P<method>\S+)\s+(?P<path>.*?)\s+\S+\"\s+(?P<status>\d+)\s+(?P<length>\S+)\s+\"(?P<referrer>.*?)\"\s+\"(?P<user_agent>.*?)\"\s+(?P<generation_time_micro>\d.+)

I get the error message re.error: bad character range w-. at position 11

I read somewhere that the \- need to be the first sequence, so in the (?P<host>[\w\-\.]*) part I switched it around to (?P<host>[\-\.\w]*). But then I get the error message [DEBUG] Invalid line detected (line did not match).

How can I get this to work, or is it plain not possible to import the page generation time when piping through Apache?

Many thanks in advance :slight_smile: