Skip to content

Observability

The proxy reports its operation through three channels: structured logs, a metrics line written every minute, and the management API with its web interface, which show current statistics, a traffic history and an activity log. Together they answer three questions: whether routing works, how well the mapping cache performs, and whether a backend has become unhealthy.

The proxy logs with structured tracing to standard output. The verbosity is set by server.log_level, info by default, and can be overridden with the RUST_LOG environment variable. Both are read at startup only.

Each connection is logged within a span that records the listener, the protocol and the peer address of the TCP connection. Behind a load balancer that sends PROXY headers, peer is the load balancer’s address.

The two main levels differ in detail:

  • At info, the proxy logs listener binds (listening), the start of the management interface (admin listener started), the end of each authenticated mail session with its byte counts and duration (session closed), destinations marked down and recovered, every management action, and warnings, such as an unreachable mail backend (backend unavailable) or a mapping store that returned an undeclared destination.
  • At debug, it adds the retries of backend connections, failures attributed to clients, the routing decision of each mail connection (routing decision), and the failures of HTTP requests (http backend dial failed) and SMTP pass-through sessions (connection ended). This level helps when investigating one account.

HTTP requests and pass-through sessions that succeed are not logged individually, so an unreachable HTTP backend shows at info level only as 502 Bad Gateway to the client, and in the destination’s health.

The management interface logs its own security events as warnings: a rejected token (admin 401 unauthorized, with the client address and the path), a failed sign-in (admin session login failed), an address locked out after repeated failures (admin client address locked out), refused connections (admin connection limit reached, at most once a minute), and every saved change to listeners or destinations (admin changed listeners or destinations). These lines, and the warning that the management interface is bound to a non-loopback address, are described under Security.

Account identifiers in the log lines of management actions are shortened to their first two characters followed by a hashed tag, such as al***#9addc7e7. The tag is stable while the process runs, so the same account can be followed across lines without full addresses in the log, but it changes after a restart.

Every minute, the proxy logs a metrics line with the cumulative cache hits and misses, the hit rate as a percentage, and the number of active connections. A line has this shape (the values are illustrative):

INFO metrics cache_hits=18234 cache_misses=412 hit_rate_pct=97.79 active_connections=1530

The hit rate is the main health signal of the mapping layer. A high rate shows that most connections resolve from memory. A persistently low rate suggests one of two problems: the cache lifetimes are too short for the connection pattern, or the number of active accounts exceeds the cache bound, cache_max_entries or cache_max_bytes.

The same figures, with the number of cached entries, are returned by GET /api/v1/cache on the management API, which suits collection by an external monitoring system. GET /api/v1/overview adds session counts per protocol, login counters, destination states and the most active accounts, and GET /api/v1/metrics/series returns the last hour of samples taken every 10 seconds, which the overview chart of the web interface draws.

While the proxy runs, the management interface answers GET /healthz with 200 OK and the body ok, without authentication. The container image’s health check uses this endpoint, and it also suits the liveness probe of a load balancer or orchestrator. The endpoint is exempt from the lockout of addresses with failed sign-ins, so a monitoring probe that shares an address with a misbehaving client keeps working, but it is subject to the connection limits of the management interface.

GET /api/v1/destinations reports, for each destination, whether the circuit breaker described under Destinations considers it up, degraded or down, the current failure streak, the number of distinct clients behind it, and the last failure with the stage it occurred at. It is the quickest way to tell whether a routing problem comes from an unreachable backend. The destinations page of the web interface shows the same report, and a countdown until a destination that is down accepts logins again.

A destination marked down after a temporary outage does not have to wait for its cooldown. POST /api/v1/destinations/<name>/reset, or Reset health in the web interface, returns it to service at once.

The proxy keeps the last 512 events in memory: management actions such as sign-ins, mapping changes, kicks and cache invalidations, health transitions of destinations, and saved or reloaded configurations. Each event records when it happened and, for management actions, which session or token performed it and from which address. The log is shown on the activity page of the web interface and returned by GET /api/v1/events. It starts empty at every restart, so a durable record of management actions comes from the log lines above.