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

Import fails with Error message #321

Open DieWebAgenten opened 2 years ago

DieWebAgenten commented 2 years ago

The following import statement for log files fails with the following error message:

python /var/www/vhosts/xxx.de/misc/log-analytics/import_logs.py --url=http://xxx.de access.log

Any hints or help would be very much appreciated, thanks!

Traceback (most recent call last): File "/var/www/vhosts/xxx/misc/log-analytics/import_logs.py", line 1588, in _call_api return json.loads(res) File "/usr/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Traceback (most recent call last): File "/var/www/vhosts/xxx/misc/log-analytics/import_logs.py", line 2684, in resolver = config.get_resolver() File "/var/www/vhosts/xxx/misc/log-analytics/import_logs.py", line 1131, in get_resolver return StaticResolver(self.options.site_id) File "/var/www/vhosts/xxx/misc/log-analytics/import_logs.py", line 1664, in init 'SitesManager.getSiteFromId', idSite=self.site_id File "/var/www/vhosts/xxx/misc/log-analytics/import_logs.py", line 1647, in call_api return self._call_wrapper(self._call_api, None, None, method, *kwargs) File "/var/www/vhosts/xxx/misc/log-analytics/import_logs.py", line 1599, in _call_wrapper response = func(args, **kwargs) File "/var/www/vhosts/xxx/misc/log-analytics/import_logs.py", line 1590, in _call_api raise urllib.error.URLError('Matomo returned an invalid response: ' + res.decode("utf-8") )

sgiehl commented 2 years ago

@DieWebAgenten Sorry to hear you are having trouble importing log files. Is your log file encoded with utf-8? Also which version of python are you using?

ProfEibe commented 2 years ago

Got the same problem. My access_log file has charset=us-ascii Is there a way to tell matomo that I have another encoding? Or do I have to change my log encoding somewhere in my server-settings?

sgiehl commented 2 years ago

Do you have QueuedTracking enabled in Matomo? If so, maybe this solves your issue: https://github.com/matomo-org/matomo-log-analytics/pull/324

ProfEibe commented 2 years ago

Hm ok, it was my mistake, I thought the --url parameter should be my site I want to track instead of the matomo installation. In the quickguide this was a bit missleading, I found my solution in the readme and documentation.

yisyang commented 2 years ago

Had the issue here as well, although turned out in my case it's because I didn't include the https:// for my URL. The script probably didn't like the redirect.

kacnje commented 2 years ago

Agree. I had the same problem. I used the URL of my tracking website ...