Mirko Milovanovic 58369fccaf
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m5s
docs: add reference to MongoDB Docker Compose examples in README
2025-02-11 11:17:47 +01:00
2025-02-06 00:54:11 +01:00
2025-02-05 01:50:24 +01:00
2025-02-05 01:50:24 +01:00

PeerTube collector

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.

Prerequisites

Linux based OS with the following:

Software:

  • Docker Engine Community version is required. To install Docker CE, follow the official install instructions.

Ports:

Docker to Host:

  • 4444 (Selenium)

Ports can be opened in the host machine's firewall with:

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:

ufw allow 50000:60000/udp
ufw allow 27107/tcp

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd peertube-collector
    
  2. Create and configure the environment file based on the .env.example file:

    cp .env.example .env
    
  3. Ajust the firewall settings to allow the necessary ports if needed

  4. Start the Docker containers:

    docker compose up
    

    or in detached mode:

    docker compose up -d
    

The collector will start gathering WebRTC stats from the Selenium container and sending them to the Telegraf service.

To stop the Docker containers run: docker compose down -v

Monitoring

A noVNC server is available at http://localhost:7900 to monitor the Selenium container. The password is secret.

Components

Docker Compose

The docker-compose.yml file defines the following services:

  • selenium: Runs a Selenium standalone Chromium container.
  • telegraf: Collects and sends metrics to the specified output.
  • collector: Runs the main Python application to collect WebRTC stats.

Dockerfile

The Dockerfile sets up the Python environment and installs the necessary dependencies to run the main.py script.

Main Python Script

The main.py script sets up the Selenium WebDriver, collects WebRTC stats, and sends them to the Telegraf service.

WebRTC Internals Exporter

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/

Server

The repository contains a server directory with a simple MongoDB server (with initializations scripts) and WebUI that serves the WebRTC stats collected by the collector.

Based this awesome example configuration: MongoDB Docker Compose examples.

Setup

  1. Change to the server directory:

    cd server
    
  2. Create and configure the environment file based on the .env.example file:

    cp .env.example .env
    
  3. Start the Docker containers:

    docker compose up
    

The WebUI control panel will be available at http://localhost:8081.

Description
No description provided
Readme MIT 1.7 GiB
Languages
Python 39.2%
JavaScript 28.7%
Shell 24.9%
Dockerfile 4.9%
HTML 2.1%
Other 0.2%