Skip to content

[pg_stat_statements] Strip special characters from query #1166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ussrlongbow
Copy link

Same queries from Windows and Linux clients to PostgreSQL may appear as different texts in pg_stat_statements.query having same query ID, because of different line breaks, which blocks proper matching query text to metrics with queryid label in Prometheus.
Example:

# Series from two replicas, one used by Windows client, another by Linux
$ curl -s 'http://prometheus.local:9090/api/v1/series?match[]=pg_stat_statements_query_id%7Bqueryid=%220000000000%22%7D' | jq .data.[].query 
"SELECT\r\n    "Username"\r\nFROM\r\n    \"Users\"\r\nWHERE\r\n        \"UserID\" = $1"
"SELECT\n    "Username"\nFROM\n    \"Users\"\nWHERE\n        \"UserID\" = $1"

This pull request adds option --[no-]collector.stat_statements.strip_special to remove such symbols from query output.

Authors:
@ussrlongbow
@freehck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant