Out-of-band Grafana and native OTLP on a 6-instance Viaalink Relay
Six Viaalink Relay instances on four continents push metrics and logs over native OTLP to a Grafana stack that stays up when a Relay goes down. Plus the Caddy, Loki, and Prometheus bugs that bit us on the way, and the fixes.
Running a single Viaalink Relay for home apps or side projects? You do not even need Grafana. The built-in dashboard at /_relay/dashboard already gives you live traffic, monthly usage, and a World map with zero extra servers to maintain.
Once you operate six instances spread across four continents, you want multi-week graphs, side-by-side peak comparisons, and central log search. That is why we built a native OTLP exporter straight into Relay v1.42.1 and connected our whole fleet to an independent Grafana stack.
This post covers why the monitoring must live outside the Relay it watches, what a live burst across six regions looks like in Grafana, and three bugs in Caddy, Loki, and Prometheus that each cost us an evening.
1. Why you should never put Grafana behind the same Relay
Every Relay stays intentionally lightweight and does not run a heavy time-series database on the traffic server itself. When you want multi-week retention and searchable log history, Grafana, Prometheus, and Loki are the right next layer.
Instead of asking operators to run a third-party monitoring agent, we wrote a lean OpenTelemetry OTLP exporter straight into the Relay binary. With two flags (--otlp-endpoint and --otlp-headers), each instance pushes standard JSON metrics (including true Docker caps via cgroup v2) and IP-hashed logs every 15 seconds.
That raises one classic trap: fate-sharing. Suppose your Relay drops offline at 03:00, and Grafana plus your OTLP receiver sit behind that exact same Relay. Your dashboard and alerts go dark at the exact second the outage begins.
The fix is straightforward: separate the traffic plane from the monitoring plane. Always point OTLP to a separate office server, an independent management relay protected with Basic Auth via via expose, or a dedicated WireGuard link.
Ports used for failover & out-of-band monitoring (hover any port inline)
Architecture · Separating the traffic plane from the monitoring plane
One non-negotiable guardrail: the exporter never blocks live traffic and enforces a strict 5-second timeout. If your Grafana host reboots or goes offline, the Relay silently drops the telemetry batch and active users notice nothing.
2. Six regions live: 61.34 GB monthly transfer and a 1.82 Gb/s peak
During our load runs across Amsterdam, Nuremberg, New York, San Jose, Singapore, and Sydney, we ran a local grafana/otel-lgtm container behind an independent management relay guarded by Basic Auth. That let us verify both live graphs and persistent monthly counters across container restarts.
Each instance atomically persists its own monthly counter per bound instance ID (monthly-traffic-<nid>.json). Even across a full rolling upgrade of all 6 servers, the counter carried straight on to 61.34 GB, peaking at 1.82 Gb/s live aggregate throughput across all four continents.
3. Three bugs and one honest limit
Building the dashboard and reviewing our rolling-upgrade runbook turned up three bugs that look harmless on paper and bite in live traffic, plus one limit worth stating plainly.
When a restarting server silently dropped packets, a single 3s dial burned the whole retry window. Setting dial_timeout 500ms, lb_try_duration 5s, and active health checks fixed failover cleanly.
Caddy keeps HTTPS on :443/tcp up via healthy peers. Active SSH sessions directly on the restarting server briefly disconnect and reconnect automatically.
Loki stores host_name and detected_level as structured metadata, not stream labels. Put them after the braces in LogQL (| host_name =~ ...) or filters return empty results.
After a version bump, Prometheus keeps the old version series alive for 5 minutes. Wrapping instant PromQL queries in last_over_time(...[45s]) clears duplicate rows within 45 seconds.
Why these fixes matter in real operations
In Caddy, the ratio between two timers decides whether failover actually works: dial_timeout must be a small fraction of lb_try_duration. When both sit at 3 seconds, Caddy gives up after one stuck attempt before ever trying a healthy peer over :6223/tcp. With a 500 ms dial timeout, a 5 s retry window, a 60 s stop grace period, and the previous binary kept for rollback, we upgraded all six servers one by one without restarting Caddy.
In Loki, the trap sits in how OTLP attributes are stored. To keep indexes lean and affordable, Loki promotes only a tiny set of fields (service_name and cloud_region) into stream labels while host_name and detected_level ride along as structured metadata. Moving those filters into the LogQL pipeline immediately brought every region online.
In Prometheus, every rolling upgrade creates a brief ghost-row effect. Because service_version changes from the old tag to the new tag, both series stay alive for Prometheus’s default 5-minute staleness window, making a 6-server fleet briefly read as 12 rows. Since each Relay pushes every 15 seconds, wrapping instant PromQL queries in last_over_time(...[45s]) drops old versions cleanly after 45 seconds.
4. Turning the runbook into a repeatable AI skill
Every hard-won fix here (the hardened Caddy failover block, the 1-by-1 upgrade order with .prev rollback, and the pre-built Grafana fleet dashboard JSON) now lives inside our public via-relay skill.
Want the full story on how we build, verify, and test our AI skills, plus our living roadmap tied to Relay, CLI, Apps, and Notetaker? Read our companion post: Viaalink Skills: what broke when AI agents used our first drafts, and the five checks that fixed it, or follow the wider Relay roadmap.
Start simple with the Relay's built-in dashboard. Once you run multiple instances or want long-term graphs on :3000/tcp, point OTLP to a separate collector on :4318/tcp and import our tested dashboard JSON to skip the Loki and Prometheus gotchas altogether.
Frequently asked questions
Why should I never monitor a Viaalink Relay through the same Relay?
That creates fate-sharing: if the monitored Relay has an outage, your OTLP collector and Grafana alerts go dark at the exact same moment. Always send OTLP metrics and logs to a separate management server, WireGuard peer, or external collector.
Do I need Grafana to monitor a Viaalink Relay?
No. Every Viaalink Relay ships with a built-in zero-dependency dashboard showing live 5-second traffic, a World map, persistent monthly quotas, and live logs. Add Grafana only when you want long-term retention, custom alerts, or fleet-wide log search.
Are rolling Relay upgrades zero-downtime for both HTTP and SSH sessions?
Caddy provides zero-downtime HTTP/HTTPS failover on port 443 for routes homed on healthy peers once dial_timeout (500ms) is well below lb_try_duration (5s) with active /_relay/discovery checks. Active SSH sessions directly on the restarting instance briefly disconnect and reconnect automatically.
Why did my Grafana Loki panel show 'No data' when filtering by host name?
Loki OTLP stores host_name and detected_level as structured metadata rather than indexed stream labels. Place them after the braces as LogQL pipeline filters (| host_name =~ ...) instead of inside the stream selector.
Why did Prometheus briefly show 12 instances instead of 6 right after an upgrade?
Upgrading changes the service_version label, and Prometheus keeps the old series alive for its default 5-minute staleness window. Wrapping instant PromQL queries in last_over_time(...[45s]) clears old rows within 45 seconds.