ProxyAuth / Operations

log vs logging: how ProxyAuth separates where lines go from what an access line says

ProxyAuthObservabilityUpdated on 2026-09-18

An access layer you cannot observe is a black box with extra steps. ProxyAuth’s observability rests on two settings whose names are one letter apart, and confusing them is the most common way to end up with either no logs or far too many.

  • log chooses the transport — where every line the process emits ends up, diagnostics and access lines alike.
  • logging shapes the access line — what a per-request record contains, and which requests get one.

The practical consequence: logging.enabled: false drops access lines while keeping warnings and errors, which is usually what “turn off logging on this endpoint” means. log.type: "disabled" silences everything.

Two files, on purpose

FileContains
/var/log/proxyauth/proxyauth.logdiagnostics: warnings, errors, startup
/var/log/proxyauth/access.logone line per request

Access lines are emitted through the same tracing call as everything else, so the local transport explicitly filters the access target out of proxyauth.log. Without that filter every request would land in both files.

The transport: the log block

{ "log": { "type": "local" } }
typeBehaviourRequires
localwrites proxyauth.log directly, not stdout — same destination under systemd, OpenRC or by hand—
lokistreams to Grafana Loki, keeps a local formatted layerhost
httpbuffers lines through an in-process channel to a generic HTTP collectorwrite_max_logs (below 100 000)
disabledno subscriber at all; nothing is written, access lines included—

The example config.json shipped by the installer sets {"type": "disabled"}, so a fresh install writes nothing until you choose. Set it explicitly on day one.

Grafana Loki without an agent

{
  "log": {
    "type": "loki",
    "host": "http://loki.internal:3100"
  }
}

No promtail, no file to tail: ProxyAuth pushes to Loki itself. What it sends:

  • the label app="proxyauth" — select on {app="proxyauth"};
  • a pid field, which is how you tell processes apart;
  • only INFO and above — trace and debug stay local;
  • only events from ProxyAuth’s own modules, not noise from the underlying HTTP server.

host must be present and must parse as a URL; both are checked at startup and both are fatal. Point it at Loki, not Grafana: Grafana reads from Loki, it does not receive pushes.

The access line: the logging block

{
  "logging": {
    "enabled": true,
    "format": "[time] [[vhost]] [[ip]] - [method] [status] [path] [request-time]",
    "log_file": "access.log",
    "flush_interval_ms": 500,
    "vhosts": {
      "noisy.example.com": { "enabled": false },
      "portal.example.com": { "log_file": "portal.log" }
    },
    "routes": {
      "/healthz": false
    }
  }
}
  • enabled — proxy-wide switch, on by default so an upgrade keeps producing access lines.
  • format — compiled once at startup.
  • log_file — a filename under /var/log/proxyauth/. Absolute paths and ../ are rejected at startup.
  • vhosts — per-hostname overrides, keyed lowercase without port. They apply to every request arriving on that Host, including ones that match no route, so one domain’s volume can be turned down alone.
  • routes — per-prefix on/off, to keep every logging decision in one file.
  • flush_interval_ms — the real trade-off knob. Lines sit in memory between flushes instead of costing a syscall each. Lower shows lines sooner when tailing; higher costs fewer syscalls under load. Below about 50 ms you are mostly defeating the buffering.

Placeholders

The default format:

[time] [[vhost]] [[ip]] - [method] [protocol] [status] [length] [path] [tid:[token-id]] '[user-agent]' '[referer]' [request-time-ns]

Available tokens, grouped:

  • request: [method] [path] [query] [protocol] [host] [route]
  • client: [ip] [x-forwarded-for] [user-agent] [referer]
  • identity: [username] [token-id] [vhost]
  • response: [status] [length] [request-time] [error_detail]
  • process: [time] [cpu-usage] [memory-usage]

Every hyphenated name also accepts an underscore, and a few carry aliases for formats inherited from other proxies: [user], [tid], [timestamp], [referrer], [error].

An unknown [name] is emitted verbatim rather than dropped. A typo shows up as [stauts] in every line — much easier to spot than a column that silently vanished.

[cpu-usage] and [memory-usage] are sampled from /proc/self every resource_sample_interval_secs (default 1), and no sampler runs at all unless the format uses one of them. That keeps a syscall and a file parse off the request path, at the cost of a value up to a second stale.

Structured queries in Loki

Write the format as key=value pairs:

"format": "method=[method] status=[status] vhost=[vhost] path=[path] user=[username] ms=[request-time]"

and Loki’s logfmt parser extracts the fields directly:

sum by (vhost) (rate({app="proxyauth"} | logfmt | status >= 500 [5m]))

Per-route control

routes:
  - prefix: "/healthz"
    target: "http://127.0.0.1:8000"
    log: false
  - prefix: "/billing"
    target: "http://127.0.0.1:8000"
    log_file: "billing.log"

Resolution order: the route’s log, then logging.routes[prefix], then logging.enabled. A route log_file writes in addition to the global access log, not instead of it.

Live counters: the stats socket

With "stats": true in config.json:

$ proxyauth stats
requests/sec (last):  42
avg req/sec (10s):     38.50
avg req/sec (60s):     35.20
total requests:        918273
active sessions:       7
uptime:                1d 1h 2m 03s

This reads from /opt/proxyauth/run/stats.sock. Its owner-only permissions, inside an owner-only directory, are the authentication — no admin token, no HTTPS round-trip. For a monitoring system on another host, GET /adm/stats returns the same structure behind token_admin, and GET /adm/stats/sessions returns per-token usage counters.

Counters are per process, and every num_instances server lives in the same process, so the figures already cover the whole instance. Counters are padded to avoid false sharing between workers.

log decides where, logging decides what and for whom. Set the transport explicitly, make the format machine-readable if it is going to Loki, and silence health checks at the route rather than turning logging off wholesale.