Sanitize all SQL query fields from PostgreSQL logs
This upgrades fluent-plugin-postgresql-csvlog to v0.2.1, which normalizes SQL logs from both slow logs and statement cancellations (gitlab-org/fluent-plugins/fluent-plugin-postgresql-csvlog!8 (merged)).
Sample output for a cancellation log message:
{
"time": "2021-03-21T13:38:13.719Z",
"user_name": "gitlab",
"database_name": "gitlabhq_production",
"process_id": "63054",
"connection_from": "127.0.0.1:49126",
"session_id": "6057480b.f64e",
"session_line_num": "12",
"command_tag": "SELECT",
"session_start_time": "2021-03-21 13:20:11 GMT",
"virtual_transaction_id": "31/106836316",
"transaction_id": "0",
"error_severity": "ERROR",
"sql_state_code": "57014",
"message": "canceling statement due to statement timeout",
"detail": null,
"hint": null,
"internal_query": null,
"internal_query_pos": null,
"context": null,
"query_pos": null,
"location": null,
"application_name": "",
"fingerprint": "9b4f461e2c9c8c2d",
"sql": "SELECT COUNT(*) FROM (SELECT $1 AS one FROM \"notes\" WHERE \"notes\".\"project_id\" = $2 AND \"notes\".\"noteable_type\" = $3 AND \"notes\".\"noteable_id\" IN (SELECT \"issues\".\"id\" FROM \"issues\" WHERE (issues.confidential IS NOT TRUE) AND \"issues\".\"project_id\" = $4) AND \"notes\".\"note\" ILIKE $5 AND \"notes\".\"system\" = $6 ORDER BY \"notes\".\"created_at\" ASC, \"notes\".\"id\" ASC, updated_at DESC LIMIT $7) subquery_for_count",
"application": "web",
"controller": "search",
"action": "count",
"correlation_id": "01F1AG3DCX4PPZ5A73D6RECM2H",
"endpoint_id": "SearchController#count",
"tag": "postgres.postgres_csv",
"environment": "gprd",
"hostname": "patroni-02-db-gprd",
"fqdn": "patroni-02-db-gprd.c.gitlab-production.internal",
"stage": "main",
"shard": "default",
"tier": "db",
"type": "patroni"
}