InfluxDB2 Metrics, Static config and env variables

Hello
I'm trying to set the InfluxDB2 token and org via the following env variables:

TRAEFIK_METRICS_INFLUXDB2_ORG:
TRAEFIK_METRICS_INFLUXDB2_TOKEN:

These are set in a .env file loaded from the docker-compose yaml file

the traefik.yml static config file has:

metrics:
  influxDB2:
    address: http://influxdb:8086
    bucket: "traefik_bucket"
    addEntryPointsLabels: true
    addServicesLabels: true
    pushInterval: 10s

If I run docker exec -it traefik /bin/sh and then execute "env", it returns

TRAEFIK_METRICS_INFLUXDB2_TOKEN=<correct token>
TRAEFIK_METRICS_INFLUXDB2_ORG=<correct org>

However, Traefik logs:

level=error msg="token, org or bucket property is missing" metricsProviderName=influxdb2

How can I fix this? I don't want to add the actual token to the static config file. I would like to be able to specify that in the env file so that it is set when the container is created and loaded.

Thank you in advance

The error mentions bucket also. Try adding that ?

Caveat: I haven't used influxdb with treafik metrics.

@cakiwi Thank you.

I've already tried that but still got the same error.