feat: enhance health checks in docker-compose and improve WebRTC stats collection

This commit is contained in:
2025-02-09 02:10:53 +01:00
parent be0e0f8153
commit 7b78f54510
6 changed files with 138 additions and 268 deletions

View File

@@ -2,38 +2,37 @@
peertube-collector is a project designed to collect and analyze WebRTC statistics from a Chromium browser and export them to a MongoDB service. This project includes a Docker setup for running the necessary services.
## Working Project Structure
```
peertube-collector/
├── requirements.txt
├── telegraf.conf
├── docker-compose.yml
├── Dockerfile
├── main.py
├── .env
└── utils/
└── webrtc-internals-exporter/
```
## Prerequisites
**Linux** based OS with the following:
### Software:
- Docker (with compose support)
- Docker and Docker Compose
### Open ports on localhost/loopback interface:
### Ports:
#### Localhost (REQUIRED):
- 4444 (Selenium)
- 7900 (Selenium VNC - Optional)
If needed, you can open these ports in `ufw` by running the following commands:
Ports can be opened in the host machine's firewall with:
```sh
ufw allow from 172.30.0.1 to 127.0.0.1 port 4444
ufw allow from 172.30.0.1 to 127.0.0.1 port 7900
ufw allow from 172.30.0.0/16 to any port 4444
```
#### External (OPTIONAL):
These ports are actively used by selenium and the collector services. By defaut they should not be blocked by the firewall, but if so, they can be opened in the host machine's firewall.
- 50000:60000/udp (WebRTC)
- Needed for WebRTC NAT traversal, otherwise the browser will not connect to any peer.
The range needs to be fairly large since the port is chosen randomly by the STUN server.
- 27107/tcp (MongoDB)
Ports can be opened in the host machine's firewall with:
```sh
ufw allow 50000:60000/udp
ufw allow 27107/tcp
```
---
## Setup
@@ -48,17 +47,23 @@ ufw allow from 172.30.0.1 to 127.0.0.1 port 7900
cp .env.example .env
```
3. Ajust the firewall settings to allow the necessary ports if needed
3. Start the Docker containers:
4. Start the Docker containers:
```sh
docker compose up
```
or in detached mode:
```sh
docker-compose up -d
docker compose up -d
```
The collector will start collecting WebRTC stats from the specified PeerTube instance.
To stop the Docker containers run: `docker compose down -v`
The collector will start gathering WebRTC stats from the Selenium container and sending them to the Telegraf service.
### Monitoring
A noVNC server is available at [http://localhost:7900](http://localhost:7900/?autoconnect=1&resize=scale&password=secret) to monitor the Selenium container. The password is `secret`.
## Components
@@ -79,4 +84,18 @@ The `main.py` script sets up the Selenium WebDriver, collects WebRTC stats, and
### WebRTC Internals Exporter
The `webrtc-internals-exporter` directory contains a Chromium extension that collects WebRTC stats from the browser.
The `webrtc-internals-exporter` directory contains a Chromium extension that collects WebRTC stats from the browser.
## Working Project Structure
```
peertube-collector/
├── requirements.txt
├── telegraf.conf
├── docker-compose.yml
├── Dockerfile
├── main.py
├── .env
└── utils/
└── webrtc-internals-exporter/
```