This directory contains a minimal Docker Compose setup for running:
mtproto-zigPrometheusGrafana
The stack is intended for a VPS or any other Linux host where you want:
- the proxy exposed on a public TCP port
- the metrics endpoint available only on localhost
- Prometheus scraping metrics from the proxy container
- Grafana available over SSH port forwarding
Create zigconf.toml next to docker-compose.yml.
The important part for metrics is:
[metrics]
enabled = true
host = "0.0.0.0"
port = 9400host = "0.0.0.0" is required because Prometheus connects to the proxy from another container over the Docker network.
Edit docker-compose.yml and replace:
mtproto-zig:<change_me>with the image tag you actually want to run.
From hack/docker run:
docker compose up -dThis starts:
mtg-zigon10000:8443- Prometheus on
127.0.0.1:9090 - Grafana on
127.0.0.1:3000
Make sure that you have proper port in server.port configured. 443 is the default, but in that example we use 8443 as internal port inside container and 10000 as exposed port on the host.
On the VM:
curl -s http://127.0.0.1:9400/metrics | headPrometheus target check:
curl -s http://127.0.0.1:9090/api/v1/targets | jq .You should see mtg-zig:9400 in the target list with health: "up".
From your local machine:
ssh -L 3000:127.0.0.1:3000 <vm_ssh_user>@<vm_ip>Then open:
http://127.0.0.1:3000
Default login from docker-compose.yml:
- username:
admin - password:
admin
In Grafana:
- Open
Connections->Data sources - Click
Add data source - Choose
Prometheus - Set the URL to:
http://prometheus:9090
- Click
Save & test
This works because Grafana and Prometheus run in the same Compose network.
In Grafana:
- Open
Dashboards->New->Import - Upload mtproto-zig-grafana.json
- Select your Prometheus datasource
- Click
Import
The dashboard includes:
- active connections
- memory usage
- total throughput
- total transferred bytes
- traffic throughput graphs
- per-user active connections
- top users by throughput
- top users by transferred bytes
- The proxy metrics are exposed on
127.0.0.1:9400on the host, not publicly. - Per-user metrics are generated from users in the proxy config loaded by the current process.
- Counter-based totals reset on proxy restart, which is expected for Prometheus counters.
