Importing Traefik access logs into Matomo


I am trying to import the Traefik access log into Matomo using the python script provided here:

but it doesn't seem to support the json format of Traefik. Here is what it does support

'common': RegexFormat('common', _COMMON_LOG_FORMAT),
'common_vhost': RegexFormat('common_vhost', _HOST_PREFIX + _COMMON_LOG_FORMAT),
'ncsa_extended': RegexFormat('ncsa_extended', _NCSA_EXTENDED_LOG_FORMAT),
'common_complete': RegexFormat('common_complete', _HOST_PREFIX + _NCSA_EXTENDED_LOG_FORMAT),
'w3c_extended': W3cExtendedFormat(),
'amazon_cloudfront': AmazonCloudFrontFormat(),
'iis': IisFormat(),
'shoutcast': ShoutcastFormat(),
's3': RegexFormat('s3', _S3_LOG_FORMAT),
'icecast2': RegexFormat('icecast2', _ICECAST2_LOG_FORMAT),
'elb': RegexFormat('elb', _ELB_LOG_FORMAT, '%Y-%m-%dT%H:%M:%S'),
'nginx_json': JsonFormat('nginx_json'),
'ovh': RegexFormat('ovh', _OVH_FORMAT)

I can't use the common format because it doesn't have the Host attribute (e.g. I know I can write a regex myself but I don't think I am the first person to run into this. I would love to not reinvent the wheel. I was hoping someone would share their solution?

Many thanks!

The tool seems to support CLF, which is mostly space separated. When looking at the tests, there is no Traefik JSON file.

So you could invent the wheel and provide a pull request, so others can use it in the future, too. (Doc)

After some digging it seems that there is already a pull request for this:
Unfortunately it is 2 years old. I will see what I can do about getting it brought back to life.

That sounds great!!!

UPDATE: The Matomo import script now supports Traefik JSON access logs.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.