Log-Analytics parameter --idsite is being ignored

Hello everyone,

I am trying to import a default Apache 2.4 access_log in a fresh Matomo 3.13.2. And the tracker fails to actually send the data to the server. The installation has only one website with the idsite=1.
The BulkTracking plugin mentioned in the output is installed and active.

Do you have any hints what could be going wrong?

Here’s the errors we get in error_log:
[Thu Feb 20 15:58:24.851882 2020] [php7:notice] [pid 21222] [client 0.0.0.0:38288] Error in Matomo (tracker): Invalid idSite: ‘0’

The import command:
misc/log-analytics # ./import_logs.py -d -d --debug-tracker --enable-bots --enable-static --enable-http-errors --show-progress --token-auth=… --accept-invalid-ssl-certificate --api-url=https://matomo…de/ --url=matomo…de --idsite=1 /var/log/apache2/access_log

Console output:
2020-02-20 15:58:04,498: [DEBUG] Accepted hostnames: all
2020-02-20 15:58:04,498: [DEBUG] Matomo Tracker API URL is: http://matomo…de
2020-02-20 15:58:04,498: [DEBUG] Matomo Analytics API URL is: https://matomo…de/
2020-02-20 15:58:04,498: [DEBUG] Authentication token token_auth is: …
2020-02-20 15:58:04,498: [DEBUG] Resolver: static
0 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
2020-02-20 15:58:04,561: [DEBUG] Launched recorder
Parsing log /srv/www/opacplus…de/logs/prodLogs/access_log…
2020-02-20 15:58:04,561: [DEBUG] Detecting the log format
2020-02-20 15:58:04,561: [DEBUG] Check format shoutcast
2020-02-20 15:58:04,561: [DEBUG] Format shoutcast does not match
2020-02-20 15:58:04,561: [DEBUG] Check format iis
2020-02-20 15:58:04,561: [DEBUG] Format iis does not match
2020-02-20 15:58:04,561: [DEBUG] Check format common_complete
2020-02-20 15:58:04,561: [DEBUG] Format common_complete does not match
2020-02-20 15:58:04,561: [DEBUG] Check format amazon_cloudfront
2020-02-20 15:58:04,561: [DEBUG] Format amazon_cloudfront does not match
2020-02-20 15:58:04,561: [DEBUG] Check format w3c_extended
2020-02-20 15:58:04,562: [DEBUG] Format w3c_extended does not match
2020-02-20 15:58:04,562: [DEBUG] Check format ovh
2020-02-20 15:58:04,562: [DEBUG] Check format icecast2
2020-02-20 15:58:04,562: [DEBUG] Format icecast2 does not match
2020-02-20 15:58:04,562: [DEBUG] Check format nginx_json
2020-02-20 15:58:04,562: [DEBUG] Format nginx_json does not match
2020-02-20 15:58:04,562: [DEBUG] Check format elb
2020-02-20 15:58:04,562: [DEBUG] Format elb does not match
2020-02-20 15:58:04,562: [DEBUG] Check format s3
2020-02-20 15:58:04,562: [DEBUG] Format s3 does not match
2020-02-20 15:58:04,562: [DEBUG] Check format common
2020-02-20 15:58:04,562: [DEBUG] Format common matches
2020-02-20 15:58:04,562: [DEBUG] Format match contains 8 groups
2020-02-20 15:58:04,562: [DEBUG] Check format common_vhost
2020-02-20 15:58:04,563: [DEBUG] Format common_vhost does not match
2020-02-20 15:58:04,563: [DEBUG] Check format ncsa_extended
2020-02-20 15:58:04,563: [DEBUG] Format ncsa_extended matches
2020-02-20 15:58:04,563: [DEBUG] Format match contains 10 groups
2020-02-20 15:58:04,563: [DEBUG] Format ncsa_extended is the best match
2020-02-20 15:58:04,613: [DEBUG] Request redirected (code: 301) to ‘https://matomo…de/piwik.php?debug=1’
2020-02-20 15:58:04,761: [INFO] Error when connecting to Matomo: HTTP Error 400: Bad Request
2020-02-20 15:58:04,761: [INFO] Retrying request, attempt number 2
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
2020-02-20 15:58:14,773: [DEBUG] Request redirected (code: 301) to ‘https://matomo…de/piwik.php?debug=1’
2020-02-20 15:58:14,812: [INFO] Error when connecting to Matomo: HTTP Error 400: Bad Request
2020-02-20 15:58:14,813: [INFO] Retrying request, attempt number 3
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
^C^C851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
^C^C^C851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
851 lines parsed, 0 lines recorded, 0 records/sec (avg), 0 records/sec (current)
2020-02-20 15:58:24,828: [DEBUG] Request redirected (code: 301) to ‘https://matomo…de/piwik.php?debug=1’
2020-02-20 15:58:24,852: [INFO] Error when connecting to Matomo: HTTP Error 400: Bad Request
2020-02-20 15:58:24,852: [INFO] Max number of attempts reached, server is unreachable!
Fatal error: Server returned status 400 (Bad Request).
Is the BulkTracking plugin disabled?

Hi,

I think this might be the reason for the issue. Can you check your webserver log to see why the server redirects the URL to something that looks incorrect?

Lukas,

Thanks. That was it. Although I used --api-url with https, the script used --url (without the protocol specified) and sent requests to http which were then redirected to https. If I include the https:// in the parameter --url, too, everything works.
For some reason then it wasn’t the --idsite but the --api-url parameter not being used - but fortunately this is easy to circumvent.

1 Like