Flags and environment variables
pg-proxy -config proxy.yaml [-validate-config] [-telemetry datadog|otel|none] [-log-level LEVEL] [-trace-parameters] [-child-span-mode full|sampled]Database, listener, session, and authentication settings are in the configuration file. Telemetry is set only with flags and environment variables.
| Flag | Default | Description |
|---|---|---|
-config |
Required | Path to the configuration file. Must end in .yaml, .yml, or .json. |
-telemetry |
Unset | Telemetry preset for traces, metrics, and logs: datadog, otel, or none. When unset, each signal follows its OTEL_*_EXPORTER variable. See Telemetry configuration. |
-tracing |
Unset | otel or none. Overrides OTEL_TRACES_EXPORTER for traces only. Cannot be combined with -telemetry. Prefer -telemetry or OTEL_TRACES_EXPORTER. |
-trace-parameters |
false |
Record raw bind parameter values as db.parameters.N tags on sampled traces. SQL text is recorded either way. See Query parameters. |
-child-span-mode |
sampled with -telemetry datadog |
sampled emits DogStatsD operation metrics and skips child spans for rejected local roots. Use full to create every child span. See Child spans and operation metrics. |
-validate-config |
false |
Check the configuration file, the credential files and variables it names, local TLS files, and the telemetry flags and environment, then exit without starting the proxy. Errors are printed one per line, naming the setting, flag, or variable; credential errors name the entry by index, such as user 0. A file that cannot be decoded stops the check before the others run: a syntax error, a wrong type, or an unknown or duplicate field. YAML errors give a line, JSON type and field errors give a line and column, and a JSON syntax error gives a byte offset. Exits 0 if everything checked is valid, 1 if not. Does not connect to PostgreSQL or open the listener. |
-log-level |
INFO |
Minimum log level: DEBUG, INFO, WARN, or ERROR. Applies to stderr and OTLP logs. |
The binary does not accept positional arguments.
Environment variables
Section titled “Environment variables”| Variables | Used for |
|---|---|
OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER |
Choose otlp or none for each signal when -telemetry is unset. |
OTEL_EXPORTER_OTLP_*, OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES, OTEL_METRIC_EXPORT_INTERVAL, and other OTEL_* SDK variables |
OTLP destination, identity, and timing. See OpenTelemetry. |
DD_AGENT_HOST, DD_SERVICE, DD_ENV, DD_VERSION, DD_DOGSTATSD_*, DD_TRACE_* |
Native Datadog traces and metrics with -telemetry datadog. See Native Datadog. |
PGSSLROOTCERT, PGSSLMODE, PGOPTIONS, and other libpq PG* variables |
Defaults for backend connections, for settings the configuration file does not set. PGHOST, PGDATABASE, PGUSER, and PGPASSWORD never apply, because the binary always sets those values; an omitted password is empty unless the libpq password file (PGPASSFILE, or ~/.pgpass by default) has one. See databases. |
Any name in password_env or scram_sha_256_env |
Credentials named in the configuration file. See credential references. |
Signals and exit status
Section titled “Signals and exit status”| Event | Behavior |
|---|---|
| Ready | Logs proxy ready with the listener address after all backend pools connect and the listener opens. |
SIGINT or SIGTERM |
Stops accepting connections, drains sessions, and closes pools within proxy.shutdown_grace_period. See Graceful shutdown. |
SIGHUP |
Not handled: the signal kills the process at once, without draining sessions, unless SIGHUP was already ignored at launch, for example under nohup. It does not reload the configuration. |
| Clean shutdown | Exit status 0. |
| Invalid flags or configuration, a backend that cannot be reached at startup, or a shutdown that exceeds the grace period | Logs the error and exits with status 1. |
The binary does not reload its configuration. Restart it to apply changes to the file, credential files, or certificates.
