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
227 stars 119 forks source link

Authentnication token expires after 2 days and import fails thereafter. #326

Open dgaastra opened 3 years ago

dgaastra commented 3 years ago

Dear Matomo!

Thanks for making such a great tool. We exclusively use the log importer and cannot use any live trackers due to performance and GDPR matters:

Problem: after having started the log importer as a daemon, it stops working after 48 hours...

Startup: [DEBUG] No token-auth specified [DEBUG] No credentials specified, reading them from "/usr/share/matomo/config/config.ini.php" [DEBUG] Authentication token token_auth is: 2b63873d2d3a6afa6a49355f96ac2b3d

A token file token.php is correctly created in /matomo/tmp/cache/

Failure after 48 hours:

[INFO] The Matomo tracker identified 57 invalid requests. [INFO] The Matomo tracker identified 57 invalid requests. ...

The Web-GUI shows: Request was not authenticated but authentication was required. Set or correct a "token_auth" in your tracking request. Learn more

How can we make it work indefinitely?

Thanks Dennis.

sgiehl commented 2 years ago

Hi @dgaastra, The token created when starting the script is indeed only valid for 48 hours. If you want to run the script longer, you can simply create a app specific token manually for the super user within the Matomo UI. This can then be used with the log importer by providing it as parameter --token-auth=XXX

dgaastra commented 2 years ago

To stay independent of the GUI, and clean, would it be possible to have a parameter --token-duration=indefinitely ?

sgiehl commented 2 years ago

Sure, that would be possible. But we currently don't have the capacity to implement that soon. If you have some time left, feel free to create a PR for that. The token lifetime is actually set here: https://github.com/matomo-org/matomo-log-analytics/blob/6f9c05d705f10cc7c2ca7c0b6799816d691f8990/import_logs.py#L1052-L1058