matomo-log-analytics icon indicating copy to clipboard operation
matomo-log-analytics copied to clipboard

Import of common log format fails

Open twatzl opened this issue 4 years ago • 1 comments

Hi, I am trying to import logs from traefik.

According to https://docs.traefik.io/observability/access-logs/#format it uses common log format, so i tried importing with the parameter --log-format-name=common.

However it fails with the following error message:

2020-06-17 20:04:18,517: [DEBUG] Accepted hostnames: all
2020-06-17 20:04:18,517: [DEBUG] Matomo Tracker API URL is: http://matomo_web_1
2020-06-17 20:04:18,517: [DEBUG] Matomo Analytics API URL is: http://matomo_web_1
2020-06-17 20:04:18,517: [DEBUG] Authentication token token_auth is: <myauthtoken>
2020-06-17 20:04:18,517: [DEBUG] Resolver: static
Traceback (most recent call last):
  File "./import_logs.py", line 2640, in <module>
    resolver = config.get_resolver()
  File "./import_logs.py", line 1092, in get_resolver
    return StaticResolver(self.options.site_id)
  File "./import_logs.py", line 1618, in __init__
    if site.get('result') == 'error':
AttributeError: 'list' object has no attribute 'get'

I run the script with the following parameters:

python ./import_logs.py import_logs.py --url=matomo_web_1 --idsite=1 --token-auth=<mytoken> --auth-user=<basic_auth_user> --auth-password=<basic_auth_pw> -d --log-format-name=common --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots /logs/access.log

In my traefik config.yaml file I configured the logs as follows:

accessLog:
  filePath: "/logs/access.log"
  format: common

Any ideas on what could be the issue or how I could get the script to ingest logs from Traefik? A more descriptive error message would be helpful.

twatzl avatar Jun 17 '20 20:06 twatzl

This is not related to the log format, but a consequence of Matomo returning a list of sites, even if a single site is queried. I have provided a quick fix in my report #270, which I have closed as a duplicate of your report.

fwrite avatar Jul 10 '20 10:07 fwrite