---
title: Health check & metrics
url: https://www.tines.com/docs/admin/tunnel/health-check-metrics/
updated: 2025-01-27T14:47:15+00:00
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/llms.txt) › [Admin](https://www.tines.com/llm/docs/admin.md) › [Tunnel](https://www.tines.com/llm/docs/admin/tunnel.md)*

# Health check & metrics

*[View on tines.com](https://www.tines.com/docs/admin/tunnel/health-check-metrics/)*

## Tunnel health checks & metrics

### Health check

Health checks are handled internally within the application, to automatically restart the tunnel container in the event it enters an unhealthy state.

You can also run a health check on the tunnel using the following steps if you wish, but this is **optional**:

**Step 1: Exec into the container**

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

**Step 2: Run tunnel-cf-healthcheck.sh **

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

### 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**

```bash
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"
    deploy:
      mode: replicated
      replicas: 2  # Deploy two replicas per host
```

```bash
docker-compose up -d
```

```bash
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.

```bash
curl http://0.0.0.0:9000/metrics
```

![](https://www.datocms-assets.com/55802/1716388725-screenshot-2024-05-22-at-15-38-25.png)

**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

```bash
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

```bash
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.

```bash
curl http://0.0.0.0:9000/metrics
```

> **INFO:** You can also use a [restart policy](https://docs.docker.com/engine/containers/start-containers-automatically/#use-a-restart-policy) to make the container restart automatically (e.g. in the event of the host machine restarting): \`\--restart unless-stopped\`.
