Prometheus metrics exporter for 3X-UI panel
4.5K
3X-UI Metrics Exporter is a comprehensive tool designed to collect and export metrics from the 3X-UI Web Panel. This exporter provides detailed monitoring capabilities for various aspects of your 3X-UI, including node status, traffic flow, system performance, and user activity, making all data readily available for integration with the Prometheus monitoring system.
Compatibility: This exporter targets the 3X-UI v3.0+ API (CSRF-authenticated login). Panels older than v3.0 are not supported.
.env files, and
command-line arguments, providing maximum flexibility for different deployment scenarios.3X-UI Metrics Exporter exposes thirteen Prometheus gauges covering online users, per-client and per-inbound traffic, Xray health, and panel diagnostics.
See METRICS.md for the complete reference — every metric name, type, and label, along with example PromQL queries and the gauge-semantics caveats that matter when querying byte totals.
To collect metrics with Prometheus, add the exporter to your prometheus.yml configuration file:
scrape_configs:
- job_name: "x-ui_exporter"
static_configs:
- targets: ["<exporter-ip>:9090"]
Ensure to replace <your-panel-url>, <your-panel-username>, <your-panel-password>, and <exporter-ip> with your
actual information.
3X-UI Metrics Exporter is configured with environment variables, which can be supplied directly or through a .env
file. Every variable also has an equivalent command-line argument.
Below is a table of configuration options:
| Variable Name | Command-Line Argument | Required | Default Value | Description |
|---|---|---|---|---|
PANEL_BASE_URL | --panel-base-url | Yes | https://<your-panel-url> | URL of the 3X-UI management panel |
PANEL_USERNAME | --panel-username | Yes | <your-panel-username> | Username for the 3X-UI panel |
PANEL_PASSWORD | --panel-password | Yes | <your-panel-password> | Password for the 3X-UI panel |
INSECURE_SKIP_VERIFY | --insecure-skip-verify | No | false | Skip SSL certificate verification (INSECURE) |
METRICS_IP | --metrics-ip | No | 0.0.0.0 | IP address for the metrics server |
METRICS_PORT | --metrics-port | No | 9090 | Port for the metrics server |
CLIENTS_BYTES_ROWS | --clients-bytes-rows | No | 0 | Limit rows for clients up/down bytes (0=all; -1=disable; else top N rows) |
METRICS_PROTECTED | --metrics-protected | No | false | Enable BasicAuth protection for metrics endpoint |
METRICS_USERNAME | --metrics-username | No | metricsUser | Username for BasicAuth, effective if METRICS_PROTECTED is true |
METRICS_PASSWORD | --metrics-password | No | MetricsVeryHardPassword | Password for BasicAuth, effective if METRICS_PROTECTED is true |
UPDATE_INTERVAL | --update-interval | No | 30 | Interval (in seconds) for metrics update |
TIMEZONE | --timezone | No | UTC | Timezone for correct time display |
The exporter loads a .env file from its working directory on startup. A sample with every option and its default is
provided as .env.sample:
cp .env.sample .env
# 3X-UI panel connection details (required)
PANEL_BASE_URL=https://your-panel-url
PANEL_USERNAME=your-panel-username
PANEL_PASSWORD=your-panel-password
# General settings
UPDATE_INTERVAL=30
TIMEZONE=UTC
# Metrics server configuration
METRICS_IP=0.0.0.0
METRICS_PORT=9090
Set ENV_FILE to load the file from another location:
ENV_FILE=/etc/x-ui-exporter/.env ./x-ui-exporter
Note: A missing
.envis not an error — the exporter runs on environment variables and command-line arguments alone. A file named explicitly byENV_FILEthat does not exist is an error.
Values are applied in order of increasing precedence: the .env file, then real environment variables, then
command-line arguments. A variable already exported in the environment (or set by Docker or systemd) overrides the file,
and a flag overrides both.
There are several ways to install and run the 3X-UI Metrics Exporter, each tailored to different environments and deployment preferences. Select the installation method that aligns best with your infrastructure requirements:
Running with Docker is the recommended way to deploy the exporter: it needs no toolchain on the host, isolates the
exporter from the rest of your system, and makes updates a single pull away.
A ready-to-use docker-compose.yml is provided with the project. It reads its configuration from
a .env file, so copy the provided sample and fill in your panel details:
cp .env.sample .env
Then run:
docker compose up -d
Security Recommendation: For production deployments, it's strongly advised to enable metrics authentication by setting
METRICS_PROTECTED=trueand configuring a secure custom metrics username and password.
If you would rather run the exporter directly on the host under systemd, an installation script is available:
bash <(curl -fsSL raw.githubusercontent.com/hteppl/3x-ui-exporter/main/install.sh)
During installation, you'll be prompted to enter:
Note: The script will validate your credentials to ensure they work with your panel.
The script installs the binary to /usr/local/bin, writes your settings to /etc/x-ui-exporter/.env, and registers a
systemd service. After installation, the service will be running automatically. You can manage it with:
sudo systemctl status x-ui-exporter # Check status
sudo systemctl restart x-ui-exporter # Restart service
sudo systemctl stop x-ui-exporter # Stop service
If you prefer manual installation, download the latest binary from the releases page for your architecture.
./x-ui-exporter --panel-base-url="https://your-panel-url" \
--panel-username="your-panel-username" \
--panel-password="your-panel-password"
.env file based on .env.samplecp .env.sample .env
./x-ui-exporter
Requires Go 1.27 or newer:
go build -o x-ui-exporter .
go test ./...
You can build the Docker image locally for both AMD and ARM architectures using Docker Buildx:
docker buildx create --name multiarch-builder --use
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg GIT_TAG=$(git describe --tags --always) \
--build-arg GIT_COMMIT=$(git rev-parse --short HEAD) \
-t <registry_name>:<tag> \
--push .
To build for a specific architecture only:
docker buildx build --platform linux/amd64 -t hteppl/x-ui-exporter:latest .
Contributions to 3X-UI Metrics Exporter are warmly welcomed. Whether it's bug fixes, new features, or documentation improvements, your input helps make this project better. Here's a quick guide to contributing:
Happy contributing! If you're new to this, GitHub's guide on Creating a pull request is an excellent resource.
Maintained by @hteppl, with contributions from:
This project is licensed under the GNU Affero General Public License v3.0. See the LICENSE file for the full text.
Content type
Image
Digest
sha256:1e5a7aba3…
Size
5.4 MB
Last updated
11 days ago
docker pull hteppl/x-ui-exporter