Skip to content

Add query logging support for PostgreSQL #5123

@rahim-kanji

Description

@rahim-kanji

Description:

Having native PostgreSQL query logging inside ProxySQL would be very useful for debugging, auditing, and performance analysis.

Feature Request:

Introduce query logging for PostgreSQL with configurable options, for example:

pgsql-eventslog_default_log — enable/disable query logging
pgsql-eventslog_filename — path to the log file
pgsql-eventslog_format — define the log format (1 = Binary Format, 2 - JSON Format)
pgsql-eventslog_filesize — manage log size limits

What should be logged:

  • client — client IP:port
  • username — authenticated DB user
  • schemaname — database / schema in use
  • server — backend server IP:port that handled the work
  • hostgroup_id — routing hostgroup id
  • thread_id — ProxySQL session identifier
  • event — protocol-level event type (e.g. QUERY, PARSE, BIND, EXECUTE, CLOSE, ERROR)
  • query — full SQL text as seen by the proxy
  • digest — normalized fingerprint of the query
  • starttime — human-readable timestamp when the event started
  • starttime_timestamp_us — start time as epoch microseconds for precise ordering
  • endtime — human-readable timestamp when the event finished
  • endtime_timestamp_us — end time as epoch microseconds
  • duration_us — measured execution time in microseconds (end - start)
  • rows_sent — number of rows returned to the client for this event (nullable/0 when none)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions