Prometheus metrics exporter for X-UI panel
7.3K
X-UI Metrics Exporter is a simple tool designed to collect and export metrics from the Original X-UI Web Panel. This exporter provides some monitoring capabilities for various aspects of your X-UI, including node status, traffic flow, system performance, and user activity, making all data readily available for integration with the Prometheus monitoring system.
This is the fork of 3X-UI Metrics Exporter which is made by hteppl. It was moddified to support the legacy panel versions.
Below is a table of the metrics provided by X-UI Metrics Exporter.
Users metrics, such as online:
| Name | Description |
|---|---|
x_ui_total_online_users | Total number of online users |
Clients metrics (params: id, email):
| Name | Description |
|---|---|
x_ui_client_up_bytes | Total uploaded bytes per client |
x_ui_client_down_bytes | Total downloaded bytes per client |
Inbounds metrics (params: id, remark):
| Name | Description |
|---|---|
x_ui_inbound_up_bytes | Total uploaded bytes per inbound |
x_ui_inbound_down_bytes | Total downloaded bytes per inbound |
System metrics (version param for x_ui_xray_version):
| Name | Description |
|---|---|
x_ui_xray_version | XRay version used by X-UI |
x_ui_panel_threads | X-UI panel threads |
x_ui_panel_memory | X-UI panel memory usage |
x_ui_panel_uptime | X-UI panel uptime |
X-UI Metrics Exporter can be configured using environment variables, command-line arguments, or a YAML configuration file. These are alternative methods of configuration, and you should choose one approach for your deployment.
Below is a table of configuration options:
| Variable Name | Command-Line Argument | Required | Default Value | Description |
|---|---|---|---|---|
CONFIG_FILE | --config-file | No | N/A | Path to YAML configuration file. When provided, CLI flags are ignored |
PANEL_BASE_URL | --panel-base-url | Yes | https://<your-panel-url> | URL of the X-UI management panel |
PANEL_USERNAME | --panel-username | Yes | <your-panel-username> | Username for the X-UI panel |
PANEL_PASSWORD | --panel-password | Yes | <your-panel-password> | Password for the X-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 |
You can use a YAML configuration file to configure the exporter by providing the --config-file flag. When using a
configuration file, all settings are read from the file and any command-line arguments are ignored. The YAML
configuration file should contain the same parameters as the command-line arguments, but in YAML format.
A sample configuration file config-example.yaml is provided with the project, which you can use as a template for your
own configuration. The structure of the YAML file matches the command-line arguments.
Example YAML configuration:
# X-UI panel connection details
panel-base-url: "https://your-panel-url"
panel-username: "your-panel-username"
panel-password: "your-panel-password"
insecure-skip-verify: false
# General settings
update-interval: 30
timezone: "UTC"
# Metrics server configuration
metrics-ip: "0.0.0.0"
metrics-port: 9090
clients-bytes-rows: 0
metrics-protected: false
metrics-username: "metricsUser"
metrics-password: "MetricsVeryHardPassword"
Note: When using a configuration file with the
--config-fileflag, all settings are taken from the configuration file, and any other command-line arguments are ignored.
There are several ways to install and run the X-UI Metrics Exporter, each tailored to different environments and deployment preferences. Select the installation method that aligns best with your infrastructure requirements:
The easiest way to install the exporter is using automatic installation script:
bash <(curl -fsSL raw.githubusercontent.com/sedyh/x-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.
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"
config.yaml file based on the example configuration./x-ui-exporter --config-file=config.yaml
Important: The configuration file approach and command-line arguments cannot be combined. When using a configuration file, any command-line arguments are ignored.
Running with Docker provides an optimal solution for containerized environments, offering simplified deployment and streamlined updates.
docker run -d \
--name x-ui-exporter \
-e PANEL_BASE_URL="https://your-panel-url" \
-e PANEL_USERNAME="your-panel-username" \
-e PANEL_PASSWORD="your-panel-password" \
-p 9090:9090 \
sedyh/x-ui-exporter
Create a docker-compose.yml file:
version: "3"
services:
x-ui-exporter:
image: sedyh/x-ui-exporter
container_name: x-ui-exporter
restart: unless-stopped
environment:
- PANEL_BASE_URL=https://your-panel-url
- PANEL_USERNAME=your-panel-username
- PANEL_PASSWORD=your-panel-password
# Optional settings
# - METRICS_PORT=9090
# - UPDATE_INTERVAL=30
ports:
- "9090:9090"
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.
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 ksusonic/x-ui-exporter:latest .
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.
Contributions to X-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.
Content type
Image
Digest
sha256:1bb63aca3…
Size
5.2 MB
Last updated
9 months ago
docker pull sedyh/x-ui-exporter:v1.0.0