clickhouse-grafana icon indicating copy to clipboard operation
clickhouse-grafana copied to clipboard

Add identifying metadata on requests to the ClickHouse query log

Open oplehto opened this issue 3 years ago • 3 comments

It would be very useful to have more information of the Grafana client requests in the ClickHouse query log. This will help pinpoint those panels and users which are hitting ClickHouse backends particularly heavily.

Primarily:

  • Grafana user
  • Panel or template variable definition which initiated the query
  • Grafana query ID

Seems like the log_comment column in system.query_log could be used for storing this in JSON, although the http_referer might be more appropriate for the panel.

oplehto avatar Jul 18 '22 09:07 oplehto

we need to figure out and ensure could grafana core pass some metadata in headers we easily can add required metadata in query body with comment

Slach avatar Jul 20 '22 08:07 Slach

There are global variables in grafana, can them be used here?

https://grafana.com/docs/grafana/v8.5/variables/variable-types/global-variables/#__user

UnamedRus avatar May 22 '23 05:05 UnamedRus

Also available other

https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#__dashboard

better will implement option in QueryEditor like "send metadata" which will add comment in request with /* $__dashboard $__user */ and turn on it by default

Slach avatar Feb 13 '24 16:02 Slach