matomo-org / matomo-log-analytics

Import any kind of server logs in Matomo for powerful log analytics. Universal log file parsing and reporting.
https://matomo.org/log-analytics/
GNU General Public License v3.0
224 stars 118 forks source link

Error when importing Apache combined #344

Open liubinas opened 1 year ago

liubinas commented 1 year ago

Python 3.6.8 Matomo version: 4.13.1 Trying to import standard Apache combined log. Log directive from httpd conf: CustomLog /var/log/httpd/site.com/access.log combined

Command: ./import_logs.py --url=site.com --idsite=9 /var/log/httpd/site.com/access.log

Error:

Traceback (most recent call last):
  File "./import_logs.py", line 1588, in _call_api
    return json.loads(res)
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 4 column 1 (char 6)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./import_logs.py", line 2688, in <module>
    resolver = config.get_resolver()
  File "./import_logs.py", line 1131, in get_resolver
    return StaticResolver(self.options.site_id)
  File "./import_logs.py", line 1664, in __init__
    'SitesManager.getSiteFromId', idSite=self.site_id
  File "./import_logs.py", line 1647, in call_api
    return self._call_wrapper(self._call_api, None, None, method, **kwargs)
  File "./import_logs.py", line 1599, in _call_wrapper
    response = func(*args, **kwargs)
  File "./import_logs.py", line 1590, in _call_api
    raise urllib.error.URLError('Matomo returned an invalid response: ' + res.decode("utf-8") )
AttributeError: 'str' object has no attribute 'decode'
tixif commented 1 year ago

I had the same problem, and in facts it's not a problem...

The --url-site parameter needs to point to your matomo base url...

From the doc : The only required parameter is --url=https://analytics.example.com To specify the Matomo (Piwik) base URL. Then, you can specify one or many log files to import.