Skip to content
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

About adding query on pg_stat_statements.go #813

Open
lunyi opened this issue Jun 15, 2023 · 1 comment · May be fixed by #940
Open

About adding query on pg_stat_statements.go #813

lunyi opened this issue Jun 15, 2023 · 1 comment · May be fixed by #940

Comments

@lunyi
Copy link

lunyi commented Jun 15, 2023

Proposal

Use case. Why is this important?

I saw the code https://github.com/prometheus-community/postgres_exporter/blob/master/collector/pg_stat_statements.go
which return query_id.

The metrics are as below.
pg_stat_statements_total_time_seconds{datname="my_database",queryid="-2096205478522934330",rolname="my_role",server="192.168.50.125:5432"} 2.5185217909999476
pg_stat_statements_total_time_seconds{datname="my_database",queryid="-4651997150931843586",rolname="my_role",server="192.168.50.125:5432"} 3.6924644360000562
pg_stat_statements_total_time_seconds{datname="my_database",queryid="-8454036462511310478",rolname="my_role",server="192.168.50.125:5432"} 9.827311363999982
pg_stat_statements_total_time_seconds{datname="my_database",queryid="-8775009150173006756",rolname="my_role",server="192.168.50.125:5432"} 4.998010090999978

We need to check which query string from query_id.

“Nice to have” is not a good use case. :)

Can we add query column in pg_stat_statements.go and show qurery in the metrics?

@SuperQ
Copy link
Contributor

SuperQ commented Jun 15, 2023

We have a similar feature in the mysqld_exporter. It should be possible to implement similar features here.

Delorien84 pushed a commit to Delorien84/postgres_exporter that referenced this issue Oct 24, 2023
…tatement metrics.

The query is not added to every metrics, but instead of new metric stat_statement_query_id is introduced that contains mapping between queryId and query.

Fix prometheus-community#813

Signed-off-by: Jakub Štiller <stiller@2n.cz>
Delorien84 pushed a commit to Delorien84/postgres_exporter that referenced this issue Oct 24, 2023
The feature must be enabled via flag or via environment variable.
The query is not added to every metrics, but instead of new metric stat_statement_query_id is introduced that contains mapping between queryId and query.

Fix prometheus-community#813

Signed-off-by: Jakub Štiller <stiller@2n.cz>
Delorien84 pushed a commit to Delorien84/postgres_exporter that referenced this issue Oct 24, 2023
The feature must be enabled via flag or via environment variable.

The query is not added to every metrics, but instead of new metric stat_statement_query_id is introduced that contains mapping between queryId and query.

Fix prometheus-community#813

Signed-off-by: Jakub Štiller <stiller@2n.cz>
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 a pull request may close this issue.

2 participants