henrygd / beszel

Lightweight server monitoring hub with historical data, docker stats, and alerts.
MIT License
2.77k stars 88 forks source link

No bandwidth data on public interfaces with Tailscale #180

Open tiagobugarin opened 1 month ago

tiagobugarin commented 1 month ago

I have been experimenting with Beszel this days and managed to get the agent to work on a VPS sending data through a Tailscale tunnel to my local (home) server.

The issue I am having is that to make it work I had set the baszel-agent container network_mode to the Tailscale container instead of the host.

Is there anyway I can make it both work over Tailscale and collect data of network trafic on public interfaces?

Below is the relevant docker-compose.yml running on the VPS:

services:
  tailscaled:
    image: tailscale/tailscale:latest
    hostname: [REDACTED]
    container_name: tailscaled
    environment:
      - TS_AUTHKEY=tskey-auth-[REDACTED]
      # - TS_EXTRA_ARGS=--advertise-tags=tag:container
      - TS_STATE_DIR=/var/lib/tailscale
      - TS_USERSPACE=false
    volumes:
      - ./tailscale-nginx/state:/var/lib/tailscale
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - net_admin
      - sys_module
    restart: unless-stopped
  beszel-agent:
    image: "henrygd/beszel-agent"
    container_name: "beszel-agent"
    restart: unless-stopped
    # network_mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # monitor other disks / partitions by mounting a folder in /extra-filesystems
      # - /mnt/disk1/.beszel:/extra-filesystems/disk1:ro
    environment:
      PORT: 45876
      KEY: "[REDACTED]"
      # FILESYSTEM: /dev/sda1 # override the root partition / device for disk I/O stats
    depends_on:
      - tailscaled
    network_mode: service:tailscaled
henrygd commented 1 month ago

Using network_mode: host is the only way I've found to allow the container to access information about the host net interfaces. Even mounting /proc from the host does not work.

I don't use tailscale, so I don't know the best approach to dealing with this, but check out the related discussion here: #99.

Not sure if this helps, but the binary version of the agent does not have this problem, and you can specify a full address in the PORT env var, i.e. PORT=100.64.0.0:45876.