Overview
Metrics are quantitative measurements of the server's operation, resource use, and workload. They let administrators see how the server behaves over time, spot trends, and react to anomalies. Metric collection in Stalwart is controlled by the Metrics singleton (found in the WebUI under Settings › Telemetry › Metrics › General, Settings › Telemetry › Metrics › OpenTelemetry, Settings › Telemetry › Metrics › Prometheus).
Push and pull exporters
Two export models are supported:
- Push: the server actively sends metric samples to a collection system at regular intervals. Push is simple to configure, and metrics arrive at the collector as they are produced.
- Pull: the collection system queries an HTTP endpoint on the server at a cadence it controls. Pull lets the collector manage the scraping load and is the model used by tools such as Prometheus.
Supported backends
Stalwart supports both models through a single configuration surface:
- OpenTelemetry is used for push. It is configured through
openTelemetryon theMetricssingleton, which is a nested type with variantsDisabled,Http, andGrpc. - Prometheus is used for pull. It is configured through
prometheuson theMetricssingleton, which is a nested type with variantsDisabledandEnabled.
Both exporters can be configured at the same time when two independent collectors need the same signal.
Selecting metrics
The set of metrics exported is controlled by metrics and metricsPolicy on the Metrics singleton. With metricsPolicy set to exclude (the default), the listed metrics are suppressed and everything else is emitted; with include, only the listed metrics are emitted.
For example, to suppress the noise of auth.error and smtp.error while leaving every other metric enabled:
{
"metrics": ["auth.error", "smtp.error"],
"metricsPolicy": "exclude"
}