Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PostgreSQLLogs — PostgreSQL Server Logs

The raw Postgres engine log stream. One record per log line. This is the only category that is free to export.

Kusto query

let server = "my-pg-prd-1";
AzureDiagnostics
| where Category == "PostgreSQLLogs" and LogicalServerName_s == server
| project errorLevel_s, sqlerrcode_s, timestamp_s, processId_d,
          backend_type_s, Message, AdditionalFields

Fields

Event content

  • Message (string) — the full formatted log line (timestamp, PID, level, text).
  • errorLevel_s (string) — severity: LOG, WARNING, ERROR, FATAL, PANIC, DEBUG
  • sqlerrcode_s (string) — Postgres SQLSTATE code (00000 = success/no error).
  • timestamp_s (string) — engine-emitted timestamp of the event (UTC).
  • processId_d (number) — OS PID of the backend that produced the line.
  • backend_type_s (string) — backend type: client backend, checkpointer, autovacuum worker, walwriter
  • AdditionalFields (dynamic) — extra key/value context (e.g. locale info).

Statement fields (present when log_statement or log_min_duration_statement fires)

  • statement_s (string) — the SQL text of the logged statement.
  • detail_s (string) — extended detail, e.g. bind-parameter values for prepared statements.
  • applicationName_s (string) — value of application_name set by the client.
  • userName_s (string) — Postgres role that executed the statement.
  • databaseName_s (string) — database the statement ran against.
  • clientHost_s (string) — client hostname or IP address.
  • clientPort_d (number) — client TCP port.

Server / build metadata

  • AppType_s / ServerType_s (string)PostgreSQL.
  • AppImage_s (string) — container image of the engine.
  • AppVersion_s / ServerVersion_s (string) — engine build label.
  • ServerLocation_s (string) — environment:region (e.g. prod:francecentral).
  • Region_s (string) — region.
  • OriginalPrimaryServerName_s (string) — original primary (relevant for restored/replica servers).

Use cases — troubleshooting

  • Connection failures & auth issuesFATAL/ERROR lines: bad password, no pg_hba.conf entry, SSL required, role doesn't exist.
  • Application errors — surface SQLSTATE (sqlerrcode_s) for deadlocks (40P01), serialization failures (40001), constraint violations (23xxx), syntax errors (42xxx).
  • "Too many connections"53300 / connection-limit rejections.
  • Slow queries — statements logged via log_min_duration_statement (duration lines).
  • Crashes / restarts & recoveryPANIC/FATAL, startup/shutdown, checkpoint and recovery messages.
  • Disk / resource pressurecould not extend file, out-of-memory, temp-file warnings, disk full.
  • Replication problems — WAL sender/receiver errors, standby disconnects.
  • Lock waits / deadlocksdeadlock detected and lock-wait log entries (with log_lock_waits).
  • Config & extension load errors — failed ALTER SYSTEM, parameter and library load failures.