@@ -77,6 +77,67 @@ curl http://localhost:4443/certificate.sha256
7777# f4:a3:b2:... (hex-encoded fingerprint)
7878```
7979
80+ ### GET /health
81+
82+ A liveness and load-shedding probe for upstream load balancers.
83+
84+ - Returns ` 200 ` with the body ` ok ` when every configured threshold passes.
85+ - Returns ` 503 ` with the body ` overloaded ` , followed by one line per breached threshold, otherwise.
86+
87+ With no thresholds configured it's a pure liveness probe (always ` 200 ` ).
88+ Each threshold is independent and only enforced when set, so you can mix and match.
89+ It's unauthenticated so probes don't need a token.
90+
91+ ``` bash
92+ curl -i http://localhost:4443/health
93+ # HTTP/1.1 503 Service Unavailable
94+ # overloaded
95+ # cpu 82.1% exceeds 75%
96+ # tx 612.0MB/s exceeds 500.0MB/s
97+ ```
98+
99+ Thresholds are read from the host via the cross-platform [ ` sysinfo ` ] ( https://crates.io/crates/sysinfo ) crate.
100+ Metrics are sampled in the background every ` interval ` seconds (default 2).
101+
102+ ``` toml
103+ [web .health ]
104+ # Return 503 when global CPU usage exceeds this percentage. Accepts `75` or `75%`.
105+ cpu = 75
106+
107+ # Return 503 when memory usage exceeds a percentage of total RAM (`80%`)
108+ # or an absolute used-bytes amount (`32GB`, `32GiB`).
109+ ram = " 80%"
110+
111+ # Return 503 when aggregate received/transmitted throughput exceeds this rate.
112+ # A unit is required; lowercase `b` is bits, uppercase `B` is bytes (`4Gb`, `500MB`).
113+ # `/s` is always implied. Useful for shedding before you saturate the NIC.
114+ rx = " 4Gb"
115+ tx = " 500MB"
116+
117+ # Return 503 when the load average exceeds these limits. Each accepts a raw
118+ # value (`6.0`) or a percentage of CPU cores (`80%`, i.e. a load of
119+ # `0.8 * cores` — so `100%` is one runnable task per core). Unix only;
120+ # these keys are rejected on Windows (which has no load average).
121+ load1 = " 8.0"
122+ load5 = " 80%"
123+ load15 = " 4.0"
124+
125+ # Seconds between metric samples. Defaults to 2, floored at 1.
126+ interval = 2
127+
128+ # Defer the decision to another service. On each request the relay GETs this
129+ # URL (5s timeout); a non-2xx response or an unreachable service counts as a
130+ # breach (fail closed). Merges with the local thresholds above, so you can use
131+ # it alone to simply proxy the verdict.
132+ api = " http://localhost:9876/health"
133+ ```
134+
135+ Every key also has a CLI flag (` --web-health-cpu 75 ` , ` --web-health-ram 80% ` ,
136+ ` --web-health-rx 4Gb ` , ` --web-health-tx 500MB ` , ` --web-health-load1 8.0 ` ,
137+ ` --web-health-load5 80% ` , ` --web-health-load15 4.0 ` , ` --web-health-interval 2 ` ,
138+ ` --web-health-api http://localhost:9876/health ` ) and a matching
139+ ` MOQ_WEB_HEALTH_* ` environment variable.
140+
80141## See Also
81142
82143- [ Relay Configuration] ( /bin/relay/config ) - Full config reference
0 commit comments