-
Notifications
You must be signed in to change notification settings - Fork 104
Log HTTP headers as query_log.log_comment #1513
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
base: main
Are you sure you want to change the base?
Log HTTP headers as query_log.log_comment #1513
Conversation
|
Hey thanks for submitting this. It looks good so far, but I have some thoughts I'd like to discuss. Related PR, let me know if you've seen this: #1433 Other related PR for attaching extra information: #1470 I have asked the ClickHouse core team about expanding the My problem with I frequently see requests like this from users where they would like to log extra information with their queries for observability into their plugin usage. Some of these requests (like trying to log headers) exceed what we SHOULD be doing with a single text field. It's hacky, hard to parse, and I really think we should find a better way to do it. Maybe it's time the plugin creates its own table as a complimentary addition to the I'll forward this to some others to see what they think |
|
Hi @SpencerTorres, Thanks for your thoughtful comment. I saw #1433 when I was already midway 🙈 so decided to finish and submit this as well. I think this PR provides a more complete implementation (FE controls, user definable selection of headers - e.g. we need also alerting metadata, and JSON instead of custom string format). About overwriting the |
|
@borismattijssen Another issue I have with this feature is that logging headers can be risky in general. I think keeping track of headers is better handled by the Grafana server telemetry than the plugin. There's already an ongoing effort across plugins to prevent secrets from being logged in error messages. Trying to fit headers into I can ask the Grafana team what they think, but I don't think this PR will be merged as it is now. I appreciate the effort and workarounds you suggested though |
|
Hi Spencer, thanks for your comments. Let me address all your points here (also the comment in this thread):
|
|
Hi @borismattijssen - thank you for the contribution here 😊
I'm not entirely anti this approach but we strongly discourage users from configuring data sources with write access to their databases. The potential risk of a malicious user modifying data is unavoidable if the data source has write access. That being said, if there is no appetite to expand the Alternatively, we could extend @SpencerTorres's approach with the user information to also include dashboard & panel in the client info section. Thoughts on this? |
This would also work for us! Most important for us is to include the IDs I mentioned earlier (and preferably the titles, but this is a nice to have). |
3553f9e to
10597ad
Compare
|
Hi @SpencerTorres , I was wondering what your current thoughts are on this topic? Do you think we can work towards an implementation either through this PR, the client_info field, or with #1433? |
|
Internally I was able to persuade the team into adding a For now, I suppose it could go into the client info so long as the syntax doesn't break the current query syntax. It's hard to parse these client info strings so I'd be mindful of what tokens will end up in there. Also of course let's be careful to not include any sensitive data. I would prefer the client info approach over the comment for now though. Thanks! |
Summary
Add support for logging HTTP headers as JSON in ClickHouse
query_logvia thelog_commentfield. This enables better observability by correlating queries with their originating Grafana context (dashboard, panel, alert rule, etc.).Changes
Frontend
(?i)^(x-dashboard|x-panel|x-rule))Backend
log_commentsetting inpkg/plugin/driver.goSecurity Considerations
Headers are filtered by regex to prevent logging sensitive data. For example,
X-Grafana-Idcontains user JWT tokens and should be excluded from the whitelist pattern. The default pattern only captures dashboard/panel/rule context headers.Implementation Evolution
Test Plan