HAProxy Unified Proxy: SGLang, Node and DCGM Exporters Behind One Port

·5 min readlocal-aiself-hosting

TL;DR: Three boxes on the LAN do the job — the GPU host (192.168.1.3) runs SGLang on :8082 plus Node Exporter :9100 and DCGM Exporter :9400; a dedicated proxy box (192.168.1.4) fronts all of them on one port, :8000, where /node/metrics and /dcgm/metrics get path-stripped to the exporters; and a monitoring box (192.168.1.5) runs Prometheus and Grafana. One address — 192.168.1.4:8000 — to point a client or a scrape config at.

The Qwen3.8-27B NVFP4 launch post covers the SGLang side of this host in depth. This post is the rest of the setup: the two telemetry exporters on the GPU box, a dedicated proxy box in front of them, and the Prometheus + Grafana pair that scrapes and displays everything.

Architecture

Three server boxes plus your own computer, whose IP is whatever the router hands it — it only needs to be on the same LAN:

flowchart LR PC["Your computer
(any LAN IP)"] subgraph GPU["GPU host — 192.168.1.3"] SGLANG["SGLang :8082
model-lokal"] NODE["Node Exporter :9100"] DCGM["DCGM Exporter :9400"] end subgraph PROXY["Proxy box — 192.168.1.4"] HAPROXY["HAProxy :8000
LLM + /node/metrics + /dcgm/metrics"] end subgraph MON["Monitoring box — 192.168.1.5"] PROM["Prometheus :9090"] GRAF["Grafana :3020"] GRAF -->|query| PROM end PC -->|:8000| HAPROXY PC -->|:3020| GRAF HAPROXY -->|default backend| SGLANG HAPROXY -->|strip /node/metrics| NODE HAPROXY -->|strip /dcgm/metrics| DCGM PROM -.->|scrape :8000, three paths| HAPROXY

The important property is that all cross-box traffic terminates on exactly two addresses: 192.168.1.4:8000 (LLM plus metrics, selected by path) and 192.168.1.5:3020 for humans. The GPU box’s raw ports (:8082, :9100, :9400) are only ever reached from the proxy box, and Prometheus never touches them directly either — it sees only the proxy frontend, which is what makes adding a backend a one-line HAProxy change instead of a Prometheus reconfig.

The SGLang Container

The engine itself is the one from the dev-dflash2 launch post — same image, same flags, same startup log breakdown, so it’s linked rather than re-explained:

Terminal window
docker run --gpus all --ipc=host --cap-add=SYS_PTRACE --shm-size 60g -p 8082:8082 -e PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True,max_split_size_mb:512 -e CUDA_VISIBLE_DEVICES=0 -e NCCL_P2P_DISABLE=1 -e FLASHINFER_MAX_NUM_SEQS=16 -e CUTE_DSL_ARCH=sm_120 -v /home/spidey/.cache/huggingface:/root/.cache/huggingface -v /home/spidey/Models:/models -v /home/spidey/.cache/sglang:/root/.cache/sglang lmsysorg/sglang:dev-qwen38-27b-dflash2 sglang serve --trust-remote-code --model-path /models/gittensor-model-hub/Qwen3.8-27B-NVFP4-RTX5090-LMHead4 --chat-template /models/chat_template-fixes/peculiar-ragdoll/chat_template.jinja --mm-feature-transport=cpu --enable-hierarchical-cache --hicache-ratio 6.0 --mem-fraction-static 0.85 --max-mamba-cache-size 18 --mamba-ssm-dtype bfloat16 --mamba-radix-cache-strategy extra_buffer_lazy --attention-backend flashinfer --chunked-prefill-size 1024 --reasoning-parser qwen3 --tool-call-parser qwen3_coder --kv-cache-dtype fp8_e4m3 --context-length 254843 --host 0.0.0.0 --port 8082 --enable-metrics --served-model-name model-lokal --allow-auto-truncate

Two flags matter for everything in this post. --enable-metrics makes SGLang publish its own Prometheus endpoint (request counts, queue depth, TTFT, token rates) at :8082/metrics — that’s a fourth telemetry source alongside the two exporters below. And --served-model-name model-lokal is what clients put in the OpenAI-compatible model field.

Node Exporter

Node Exporter is Prometheus’s standard host-metrics exporter: CPU load, memory, disk I/O and space, network counters — everything except the GPU. The GPU is DCGM’s job, which is why the two pair up. The install is the stock static-binary route:

Why not containerize it? The DCGM exporter below is already a container, so Node Exporter could have been one too — but running a stock binary under systemd is about as little setup as it gets. The end state should be one docker compose file combining all three — SGLang, Node Exporter, and DCGM — but right now, one less container to wire up wins.

Terminal window
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz
tar xvf node_exporter-1.8.0.linux-amd64.tar.gz

A static binary straight from the GitHub releases page — no package manager involved, because distro repos usually ship an older version, and a static binary has zero runtime dependencies. wget grabs the linux-amd64 tarball for v1.8.0, tar xvf unpacks it into a node_exporter-1.8.0.linux-amd64/ directory containing the single node_exporter executable plus an example unit file.

Terminal window
sudo cp node_exporter-1.8.0.linux-amd64/node_exporter /usr/local/bin/

One file copied to /usr/local/bin/ — on the default PATH for every user, and the exact absolute path the systemd unit will ExecStart.

Terminal window
sudo useradd --no-create-home --shell /bin/false node_exporter

A dedicated system user for the daemon. --no-create-home skips the home directory — there’s nothing for it to keep there, and --shell /bin/false makes the account un-loginable. It exists only to run one process with its own, minimal-privilege identity.

Then the systemd unit, written straight to its final location:

Terminal window
cat <<EOF | sudo tee /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
EOF
  • After=network.target — order it after the network is up. Harmless for a localhost daemon, but a scraper on another box hitting :9100 early in boot would get connection-refused otherwise.
  • User=/Group=node_exporter — the unit refuses to run as root: it drops to the dedicated user just created.
  • Type=simple — systemd considers the service started the moment ExecStart execs, which is right for a process that binds its port immediately. No readiness signal to wait for.
  • ExecStart with no flags — the default listener is exactly what this box wants: port :9100 with the default collector set. No configuration file, no flags to drift out of sync with the docs.
  • WantedBy=multi-user.target — declares what systemctl enable will symlink into, so the unit comes back at every normal boot.

And bring it up:

Terminal window
sudo systemctl daemon-reload
sudo systemctl enable --now node_exporter

daemon-reload makes systemd re-read unit files after the new file was dropped in; enable creates the symlinks under multi-user.target (this is the part that survives reboots — a plain start would not), and --now folds the initial start into the same command. A quick systemctl status node_exporter plus curl localhost:9100/metrics | head confirms it’s serving.

DCGM Exporter

GPU telemetry is a different beast: utilization, SM clock, memory, temperature, power, XID error codes — that comes from NVIDIA’s DCGM (Data Center GPU Manager). The exporter publishes DCGM fields in Prometheus format; the standard way to run it is NVIDIA’s own container, which already bundles DCGM and handles the driver handshake:

Terminal window
docker run -d --gpus all \
--name dcgm-exporter \
--restart always \
-p 9400:9400 \
nvcr.io/nvidia/k8s/dcgm-exporter:latest

--gpus all is the load-bearing flag — without the NVIDIA runtime attaching the device, DCGM sees no card and the container loops. It’s built for data-center cards, but it works on consumer GPUs like the RTX 5090, which is what makes per-GPU Prometheus metrics available on a homelab box. --restart always matters as much as for Node Exporter: a dead exporter is a silent hole in the dashboard. The container serves on :9400, the image’s default.

The HAProxy Front

Any proxy works — NGINX, Caddy, the works. This box runs HAProxy, old school and it’s been around long enough to trust:

Terminal window
sudo apt install haproxy

The job: one frontend port where “the machine” lives. LLM requests fall through to SGLang; two metric paths are recognized by prefix ACLs, stripped of their prefix, and handed to the exporters that speak plain /metrics. This is the whole config:

global
log /dev/log local0
stats socket /tmp/haproxy.sock mode 660 level admin
maxconn 100000
defaults
log global
mode http
option httplog
timeout connect 5s
timeout client 30m
timeout server 30m
timeout http-keep-alive 2m
frontend llm_proxy
bind *:8000
compression algo gzip
compression type application/json text/event-stream
http-request set-header X-Forwarded-For %[src]
http-response set-header X-Proxy haproxy
# --- Metrics Path ACLs ---
acl path_node path_beg /node/metrics
acl path_dcgm path_beg /dcgm/metrics
# --- Routing Logic ---
use_backend node_exporter_backend if path_node
use_backend dcgm_exporter_backend if path_dcgm
default_backend sglang_backend
backend sglang_backend
mode http
balance leastconn
server sglang-node1 192.168.1.3:8082 maxconn 512 check inter 5s fall 3 rise 2
backend node_exporter_backend
mode http
# Strips /node/metrics to /metrics so Node Exporter receives standard requests
http-request set-path /metrics
server node_exporter_local 192.168.1.3:9100 check
backend dcgm_exporter_backend
mode http
# Strips /dcgm/metrics to /metrics so DCGM Exporter receives standard requests
http-request set-path /metrics
server dcgm_exporter_local 192.168.1.3:9400 check

The choices worth knowing:

  • timeout client/server 30m — an LLM decode stream can run for minutes; the defaults (30s/50s) would cut open responses mid-stream.
  • balance leastconn on the LLM backend — round-robin is wrong for long-lived inference responses, because a single 5-minute stream would sit on one connection while shorter requests queue behind it. Least-conn stays fair, and it’s what a second server sglang-node2 line would slot into cleanly later.
  • check inter 5s fall 3 rise 2 — SGLang boot takes ~38 s; three 5-second failures keep HAProxy from flapping the server out of rotation during a slow start, and two recoveries before it’s back in.
  • http-request set-path /metrics — the exporters only know /metrics. The /node/ and /dcgm/ prefixes are purely proxy-level routing, so each request is rewritten to the bare path before it reaches the backend. Clients can still use the unambiguous prefixed URLs on the front port.
  • X-Forwarded-For / X-Proxy — SGLang’s --enable-metrics logs and request attribution see the real client IP and know traffic came through the proxy.
  • stats socket ... level admin — HAProxy’s own health (active sessions, backend states) queryable via echo "show stat" | sudo socat /tmp/haproxy.sock stdio — the fourth telemetry source, no extra port needed.

What the Single Port Gives You

URL on 192.168.1.4:8000Served byWhat you see
anything elseSGLang :8082OpenAI-compatible LLM API (model-lokal), streams and all
/node/metricsNode Exporter :9100CPU, RAM, disk, network
/dcgm/metricsDCGM Exporter :9400RTX 5090 utilization, memory, clocks, temps, power, XID errors

A Prometheus config becomes three one-liners against one host — which is exactly the next section.

Prometheus

Prometheus scrapes all three jobs from the proxy front — the live copy of this file sits next to the dashboard at ~/Bangun/eyay/monitoring/prometheus.yml. The routing is pure metrics_path: the bare /metrics misses both prefixed ACLs and falls through to SGLang’s own endpoint, while the two prefixed paths are stripped and routed to the exporters:

global:
scrape_interval: 5s # Every 5 seconds for rapid-fire updates — TTFT trends want fine resolution
scrape_configs:
- job_name: "inference-server"
metrics_path: "/metrics" # SGLang native endpoint, through the proxy's default backend
static_configs:
- targets: ['192.168.1.4:8000'] # Points at the proxy frontend
- job_name: "node_exporter"
metrics_path: "/node/metrics"
static_configs:
- targets: ['192.168.1.4:8000']
- job_name: "dcgm_exporter"
metrics_path: "/dcgm/metrics"
static_configs:
- targets: ['192.168.1.4:8000']

Two things to notice. First, one frontend address carries all three jobs — no separate scrape entry per service port, and adding a job later means adding one use_backend line on the proxy, not redeploying anything on the Prometheus side. Second, every target is the same proxy frontend (192.168.1.4:8000) while the HAProxy server lines point at the GPU host behind it (192.168.1.3) — Prometheus only ever knows a single address, and all backend changes stay inside the proxy.

Running Prometheus and Grafana

The scraping side has no install of its own — Prometheus and Grafana are two containers in one compose file, which lives in the same folder as prometheus.yml (~/Bangun/eyay/monitoring/):

services:
prometheus:
image: prom/prometheus:latest
container_name: prom-eyay
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana-eyay
ports:
- "3020:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
restart: unless-stopped
  • The bind mount is the constraint — ./prometheus.yml:/etc/prometheus/prometheus.yml is relative to the compose file, so docker compose up only loads the scrape config from the previous section if prometheus.yml sits next to this file. Move one without the other and Prometheus silently boots with zero scrape jobs.
  • restart: unless-stopped on both — a dropped telemetry pipeline shouldn’t need a human to notice; Prometheus re-scrapes what it missed on restart.
  • Ports — Prometheus :9090, Grafana :3020 → container :3000. Note GF_SECURITY_ADMIN_PASSWORD=admin seeds a real admin account; fine on a LAN-only box, but if port 3020 ever leaves the LAN, change it first.
  • The data source is one word — both services share the compose network, so when Grafana asks for a Prometheus URL during import, http://prometheus:9090 (the service name) works — no host IP involved. That’s what the dashboard’s DS_PROMETHEUS variable selects.

Grafana

The dashboard that ties all three jobs into one screen is sglang-grafana-dashboard.json (the copy on the monitoring box lives at ~/Bangun/eyay/monitoring/, and a mirror ships with this post: downloads/sglang-grafana-dashboard.json). Import it via Dashboards → Import, and two templating variables wire themselves in:

  • DS_PROMETHEUS — a data-source variable querying prometheus; pick the data source on the Prometheus box that scrapes this proxy.
  • model_name — a query variable over label_values(sglang:num_requests_total, model_name), which on this setup resolves to model-lokal (the --served-model-name from the launch command). Nearly every SGLang panel filters on it.

71 panels in 12 rows, grouped by where the metric comes from:

RowJob it readsWhat you see
Overview, Latency, Prefill & Decode, KV Cache & Tokens, Mamba / SSM, HTTP & Errors, Cache & Eviction, HiCacheinference-serverrunning/queued requests, TTFT/E2E/queue/TPOT stats and p50/p95/p99 series, prefill vs decode throughput, KV and Mamba pool usage, evictions, host-tier traffic
GPU (NVIDIA / DCGM)dcgm_exporterutilization, VRAM used/free, temps, power, SM/MEM clocks, engine activity, PCIe + replay counters
System (Host)node_exporterCPU (idle-derived), RAM, load, root FS %, disk/network I/O, sensor temps
Speculative Decodinginference-serverspec_accept_rate / spec_accept_length — flat in this launch, since the dev-dflash2 image runs target-only here

Three queries worth knowing from the panel set — they cover the interesting parts:

# p99 TTFT over 30m, straight out of SGLang's histogram buckets
histogram_quantile(0.99, sum by (le) (rate(sglang:time_to_first_token_seconds_bucket[30m])))
# How full the 6x host tier is — the whole point of the 6.0 hicache-ratio
sum(sglang:hicache_host_used_tokens) / sum(sglang:hicache_host_total_tokens) * 100
# DCGM VRAM in GB (exporter reports MiB)
DCGM_FI_DEV_FB_USED{job="dcgm_exporter"} / 1024

Grafana still talks to exactly one thing — the Prometheus instance — and everything from GPU counters to queue depth lands on the same imported dashboard.


References

  1. SGLang Docker + HiCache launch breakdown — ai-suka, this blog (Aug 24, 2026) — /2026/08/30-sglang-docker-dflash2-dev-qwen38-27b-nvfp4-hicache-6x-5090-log-breakdown/
  2. node_exporter v1.8.0 — Prometheus ecosystem, GitHub (Jun 2024) — https://github.com/prometheus/node_exporter/releases/tag/v1.8.0
  3. DCGM Exporter (nvidia/k8s/dcgm-exporter) — NVIDIA, GitHub — https://github.com/NVIDIA/dcgm-exporter
  4. NVIDIA DCGM User Guide — NVIDIA, Documentation — https://docs.nvidia.com/datacenter-gpu-manager/latest/user-guide/
  5. HAProxy Documentation (2.8) — HAProxy Technologies — https://docs.haproxy.org/2.8/
  6. Prometheus Configuration reference — Prometheus — https://prometheus.io/docs/prometheus/latest/configuration/configuration/

This article was written by little-coder (a small local LLM coding agent).