Health Check & Metrics

Tunnel health checks & metrics 

Health Check 

You can run a health check on the tunnel using the following steps:

Step 1: Exec into the container

docker exec -it <container-id> /bin/sh

Step 2: Run tunnel-cf-healthcheck.sh

/home/tines/tunnel-cf-healthcheck.sh

Step 3 (Optional): Configure healthcheck for docker-compose

Optionally you can configure a healthcheck using the script in your docker-compose.yml file by adding the following:

healthcheck:
  test: ["CMD", "/home/tines/tunnel-cf-healthcheck.sh"]
  interval: 30s
  timeout: 10s
  retries: 3

You can verify the health check status using docker-compose ps and view the STATUS column:

Metrics 

You can view tunnel metrics from inside or outside the docker container via the /metrics endpoint. If you need to override the default port which is 9000 you can run the tunnel container with the env var TUNNEL_METRICS_PORT.

Option 1: run the container via docker-compose.yml and exec into container

version: '3.9'

services:
  tines_tunnel:
    image: tines-tunnel:latest  # Make sure to use the correct image name and tag
    environment:
      TUNNEL_METRICS_PORT: "9000"
      TINES_TUNNEL_SECRET: "secret"
    healthcheck:
      test: ["CMD", "/home/tines/tunnel-cf-healthcheck.sh"]
      interval: 30s
      timeout: 10s
      retries: 3
    deploy:
      mode: replicated
      replicas: 2  # Deploy two replicas per host
docker-compose up -d
docker-compose exec tines_tunnel /bin/sh

You can use tools such as cURL, wget, or others to fetch the metrics from the tunnel inside of the container.

curl http://0.0.0.0:9000/metrics

Option 2: expose the /metrics endpoint outside the container

The -p option is required to publish the port to the host. This value is needed whether or not you are overriding the TUNNEL_METRICS_PORT e.g -p 0.0.0.0:${TUNNEL_METRICS_PORT}:<container_port>

See docker-compose.yml example

version: '3.9'

services:
  tines_tunnel:
    image: tines-tunnel:latest  # Make sure to use the correct image name and tag
    ports:
      - "9000:9000"  # This maps the container's port 9000 to the host's port 9000
    environment:
      TUNNEL_METRICS_PORT: "9000"
      TINES_TUNNEL_SECRET: "secret"
    healthcheck:
      test: ["CMD", "/home/tines/tunnel-cf-healthcheck.sh"]
      interval: 30s
      timeout: 10s
      retries: 3
    deploy:
      mode: replicated
      replicas: 2  # Deploy two replicas per host

See docker run example

docker run \
-d \
--name tines-tunnel \
--env TUNNEL_METRICS_PORT=9000 \
--env TINES_TUNNEL_SECRET="YOUR_TUNNEL_SECRET" \
-p 0.0.0.0:9000:9000 \
tines/tines-tunnel:latest

Once the above configuration is in place, you can use tools such as cURL, wget, or others to fetch the metrics from the tunnel outside of the container.

curl http://0.0.0.0:9000/metrics
Was this helpful?