Strange healthcheck behaviour

Hello! I am trying to set up a healthcheck for cli (traefik healthcheck) but it fails for some reason with 404 error. I have the following global config:

[global]
  checkNewVersion = true

[providers]
  providersThrottleDuration = 10
  [providers.docker]
    endpoint = "unix:///var/run/docker.sock"
    useBindPortIP = false
    exposedByDefault = false
    swarmMode = true
    watch = true

  [providers.file]
    directory = "/etc/traefik/services"
    filename = "dynamic.toml"
    watch = true    

[api]
  dashboard = true
  insecure = false

[ping]
  entryPoint = "ping"

[log]
  format = "common"
  level = "ERROR"

[entryPoints]
  [entryPoints.web]
    address = ":80"
  [entryPoints.websecure]
    address = ":443"
  [entryPoints.traefik]
    address = ":8080"
  [entryPoints.ping]
    address = ":8082"
  [entryPoints.metrics]
    address = ":8083"

[certificatesResolvers.default.acme]
  email = "admin@CHANGE.ME"
  storage = "/etc/traefik/acme/acme.json"
  caServer = "https://acme-v02.api.letsencrypt.org/directory"
  keytype = "EC256"
  [certificatesResolvers.default.acme.tlsChallenge]

[tls.options]
  [tls.options.default]
    minVersion = "VersionTLS12"
  [tls.options.mintls13]
    minVersion = "VersionTLS13"

[metrics]
  [metrics.prometheus]
    buckets = [0.1,0.3,1.2,5.0]
    addEntryPointsLabels = true
    addServicesLabels = true
    entryPoint = "metrics"

I am running latest traefik:montdor (2.0.5) in docker with bind-mounted file config and no arguments.
Now, when I get into container with docker exec and try probe the health with

traefik healthcheck

I get this:

INFO[0000] Configuration loaded from file: /etc/traefik/traefik.toml 
Bad healthcheck status: 404 Not Found

Of course I can manually wget localhost:8082/ping and it returns my 200 code, but why the cli command is failing? Am I doing something wrong?

Hi @vbessonov,

The healthcheck command uses the static configuration to know how to reach the ping endpoint.
The entrypoint configured in the static configuration wasn't applied, a PR https://github.com/containous/traefik/pull/5867 will fix the issue.

Some comments on your configuration:

  • If you define a directory in the providers.file, all files in this directory will be loaded, you can't specify a filename.
  • The tls.options is a dynamic configuration and you defined it in the static configuration. You need to move it in your dynamic configuration.
2 Likes

@jpd what confuses me about traefik healthcheck is that it seems that it only works if you give the same configuration to the traefik you are checking and the traefik you are checking the first traefik with. So if your traefik instance runs with, say command line paramters that were supplied in docker-compose, you will need the same parameter with healthcheck? At this point curl works as well...

@zespri the command has been created for the v1 where the default Docker image was a FROM SCRATCH image: no curl.

Thank you. Not directly related and very minor: the docs for healthcheck say healthcheck [command] but there is no commands healthcheck accepts, at least nothing obvious.

This doc section have been generated based on the CLI help, so it's just a generic help.

Oh, thank you! One more thing. I'm not sure I am getting this "dynamic/static" correctly. Am I right if I say that traefik.toml palced in /etc/traefik and loaded on traefik loading (with entrypoints and some basic config) is static and pluggable file (like dynamic.toml in my config above) is dynamic? So I should move all the [tls.options] block to that dynamic.toml file?

Yes, the traefik.toml will be used as default configuration and contains the static configuration. It will be loaded once at startup. And yes, you have to move the tls.options configuration to your dynamic.toml file or to any configuration file that is watched by the File Provider.
You can find more details in the documentation.

1 Like

Hi there,
I still don't get it.
I have a traefik container running started by means of a docker-compose file and do later on

root@Ubuntu18:~# docker exec -it traefik traefik healthcheck --ping
INFO[0000] Configuration loaded from flags.
Bad healthcheck status: 404 Not Found

how can I pass the test?