-
Notifications
You must be signed in to change notification settings - Fork 61
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
[#159] Add new pool metric pgagroal_query_count and Query rate
panel
#161
Conversation
This would count all client requests as a query - it would be better to just count the actual SQL queries. See https://www.postgresql.org/docs/devel/protocol-message-formats.html for the message protocol - you will need support for the simple query and the prepared query format. You can use https://github.com/jesperpedersen/pgprtdbg for protocol debugging. You can likely reuse code from Only |
Thanks for your guidance. I am implementing the filtering of SQL queries by protocol key info. I will push newer code soon. |
@jesperpedersen I have check the message kind in
So the query_count should be increased by 'Q' 'P' and 'E'. The newer commit includes that implementation. |
src/libpgagroal/pipeline_perf.c
Outdated
@@ -97,6 +97,7 @@ performance_client(struct ev_loop *loop, struct ev_io *watcher, int revents) | |||
wi = (struct worker_io*)watcher; | |||
|
|||
status = pgagroal_read_socket_message(wi->client_fd, &msg); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
White space
src/libpgagroal/pipeline_session.c
Outdated
@@ -220,6 +220,11 @@ session_client(struct ev_loop *loop, struct ev_io *watcher, int revents) | |||
{ | |||
if (likely(msg->kind != 'X')) | |||
{ | |||
if (msg->kind == 'Q' || msg->kind == 'P' || msg->kind == 'E') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P
is Parse which we shouldn't count as a query, as B
(Bind) won't need it after 5 statements.
Lets start with Q
and E
in this category.
@@ -236,6 +236,11 @@ transaction_client(struct ev_loop* loop, struct ev_io* watcher, int revents) | |||
{ | |||
if (likely(msg->kind != 'X')) | |||
{ | |||
if (msg->kind == 'Q' || msg->kind == 'P' || msg->kind == 'E') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
You are missing the reset part for the new metric |
Done. I found that a 'P' message(parse) can be sent by |
Thanks for your contribution ! |
Issue
#159
Task
pgagroal_query_count
which characterizes the number of queries.Query rate
in Grafana dashboard,