Expose metrics from PeerTube Docker

Hello all,

I have deployed PeerTube on Docker and everything works perfectly but I can’t expose the PeerTube metrics from the container. I have enabled the metrics using the production.yaml and when I exec into the peertube container and do « curl localhost:9091/metrics » I get the metrics. But I can’t expose them outside of the container. I have forwarded the port in the docker-compose.yml with « - 9091:9091 » under « ports: », but still I can’t curl the metrics in the docker host.

Do you have any ideas on what I might miss?

Hello,

I think you have to change the listening interface: PeerTube/production.yaml.example at develop · Chocobozzz/PeerTube · GitHub

Hey Chocobozzz,

thanks for the quick reply!

I changed the listening interface to the docker host (192.168.1.99) but it won’t spin the container.
In the docker logs I can see this:

Error: listen EADDRNOTAVAIL: address not available 192.168.1.99:9091
    at Server.setupListenHandle [as _listen2] (node:net:1446:21)
    at listenInCluster (node:net:1511:12)
    at doListen (node:net:1660:7)
    at wrappedLookupCallback (/app/node_modules/@opentelemetry/instrumentation-dns/build/src/instrumentation.js:129:29)
    at processTicksAndRejections (node:internal/process/task_queues:84:21) {
  "error": {
    "stack": "Error: listen EADDRNOTAVAIL: address not available 192.168.1.99:9091\n    at Server.setupListenHandle [as _listen2] (node:net:1446:21)\n    at listenInCluster (node:net:1511:12)\n    at doListen (node:net:1660:7)\n    at wrappedLookupCallback (/app/node_modules/@opentelemetry/instrumentation-dns/build/src/instrumentation.js:129:29)\n    at processTicksAndRejections (node:internal/process/task_queues:84:21)",
    "message": "listen EADDRNOTAVAIL: address not available 192.168.1.99:9091",
    "code": "EADDRNOTAVAIL",
    "errno": -99,
    "syscall": "listen",
    "address": "192.168.1.99",
    "port": 9091
  }

I think it has to do with the peertube container having the default network with IP 172.18.0.x, so it can’t see the docker host network. Any ideas on how I can attach both networks to the container so it will see 172.18.0.x for the peertube webserver and 192.168.1.x for the metrics?

Update: I tried with 172.17.0.1 which is the IP of the docker host inside the containers, but still throws the same error. The funny thing is that this IP is ping-able from inside the container…

Ok, found it!
Have to change it to 0.0.0.0 since this is what is being forwarded with - "9091:9091" under ports:.
Now the metrics are exposed in the docker host.