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
Document request logging configuration #4934
Conversation
6a3bde2
to
04338a5
Compare
You might need to run |
04338a5
to
793cf9d
Compare
http: | ||
config: | ||
- path: /api/v1/query | ||
port: 10904 |
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.
What's this port config for?
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.
That would be coming from https://github.com/thanos-io/thanos/blob/main/pkg/logging/yaml_parser.go#L34
However I did not look too deeply into the implementation. Just double checked the original example https://gist.github.com/yashrsharma44/02f5765c5710dd09ce5d14e854f22825 against what was exposed by those types.
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.
It would be nice to document this field in more detail. Maybe @yashrsharma44 can help answer this. I feel confused when I saw this config TBH.
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.
Agree, I just don't have enough context to provide more info. I had a look at #3862 but it didn't tell me much.
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.
I believe this is to specify which port to log the requests on - this might make sense in the context of components exposing multiple HTTP endpoints (e.g. receiver). But I'm also thinking if we could make the user experience here more intuitive and somehow figure out which HTTP server it is based on paths? 🤔
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.
@dwilliams782 it is looking for an exact match. regex matching etc is not supported - I've documented the behaviour on https://github.com/thanos-io/thanos/pull/4934/files#diff-1a5e57d66b08bec5a71860d67f06912a004f03368c36910099d4ffae12970c7dR61
Omitting the config will match all as you have seen.
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.
@philipgough how do we know what an exact match is? AFAIK my config above should be an "exact" match, in that, they are the three endpoints being emitted (when running without config) and that is my HTTP port. How else can I diagnose this?
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.
@dwilliams782 - the exact match would include any query params etc - I think it would be beneficial to be able to add \/api\/v1\/query\?.+
for example, but that is for another issues.
And I am sorry I don't have all the answers since I put this together by stumbling through the same pain points as you are right now :)
My diagnosis was done by running locally and outputting logs and stepping through the debugger - not aware of a better way.
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.
Ah I see! Perhaps your example of using config should specify that any parameters need to match too? That wasn't obvious to me.
Yeah, I really appreciate your efforts here. I'm not expecting you to know the answers, but hopefully asking the questions can help improve the documentation when we do stumble on the answers. Cheers!
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.
Yeah no worries, good point, I can add a couple of examples with query params to the example conf and it might make it more obvious
By the way @matej-g has created #4961 to track some of the issues and figure out improvements to this so might be worth keeping an eye on that going forward or logging any suggestions you have (not for existing config/implementation) for improving things.
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.
So glad we'll have this important feature documented better ❤️ Adding few comments.
http: | ||
config: | ||
- path: /api/v1/query | ||
port: 10904 |
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.
I believe this is to specify which port to log the requests on - this might make sense in the context of components exposing multiple HTTP endpoints (e.g. receiver). But I'm also thinking if we could make the user experience here more intuitive and somehow figure out which HTTP server it is based on paths? 🤔
f4277f0
to
743e872
Compare
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.
This is great, thanks for digging in and documenting the behavior! Just few smallish suggestions.
docs/logging.md
Outdated
|
||
## Configuration | ||
|
||
Configuration can be supplied for either gRPC, HTTP or both. Options can be supplied globally, which is applied to both gRPC and HTTP, or individually to either or both protocols. |
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.
Configuration can be supplied for either gRPC, HTTP or both. Options can be supplied globally, which is applied to both gRPC and HTTP, or individually to either or both protocols. | |
Configuration can be supplied for either gRPC, HTTP or both. Options can be supplied globally, which is applied to both gRPC and HTTP, or individually to either of both protocols. |
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.
I think my wording is correct here actually but I see it can be confusing. Does this work for you:
Configuration can be supplied globally which applies to both `grpc` and `http`.
Alternatively `http` and/or `grpc` can be configured independently.
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.
Sounds good!
|
||
### Options | ||
|
||
Valid `level` for `options` should be one of `INFO`, `WARNING`, `ERROR` or `DEBUG`. |
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.
So what does level
set? 🤔
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.
So level
, from what I can see provides an additional filter. Take the following example
I have enabled --log.level=debug
globally and request logging is enabled with ERROR
- I will not see any of the debug
logs emitted from the http middleware.
This could be seen as a nuisance or as a feature :)
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.
Understood, then let's keep it!
7c0b856
to
71ae8d9
Compare
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.
I think this is looking good now, great improvement! Good job @philipgough!
71ae8d9
to
dfd88d4
Compare
I've found this PR when trying to work out how the logging config works. Thanks a lot for your effort! |
* Log details prior to the request and when the request completes - Pre request log is made at `debug` level. | ||
|
||
```yaml | ||
options: |
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.
IIUC - the default is ERROR
- https://github.com/thanos-io/thanos/blob/main/pkg/logging/grpc.go#L45
Hi thanks. Let's get this merged. Could you rebase from main as we've changed some tests and these are now missing? |
5d45cde
to
133ae8b
Compare
133ae8b
to
dfe0249
Compare
@wiardvanrij - rebased - docs check seems to be failing but not sure that it is related if you wouldn't mind running the check again? |
Re-ran the job but it really has a diff in it. It should make a change on your doc when you run it locally, that needs to be committed. I can take a look later, because I lack a bit of time at the moment to help you out right now. |
Signed-off-by: Philip Gough <philip.p.gough@gmail.com>
26ab0d0
to
53724fd
Compare
Noted, I ran |
@philipgough , are you sure you have rebased correctly? We made some changes in our docs/formatting. Perhaps manually diff your Makefile with that of ours in main? Erm, @matej-g why we have the docs? Maybe we can make it better so we don't have this confusion? (lets follow up? :D ) |
I think you need to run |
solution seems to have been |
Signed-off-by: Philip Gough <philip.p.gough@gmail.com>
53724fd
to
5406919
Compare
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.
Everything is passing now 🎉 May we requests a merge @wiardvanrij? 🙂
Yes, this is better than what we have now. Thanks so much @philipgough and sorry for the bad experience on getting all the tests done :( P.s. If people find things that are not correct or require extra input, I encourage those to iterate on this document and create a PR to improve it. For now, let's move forward. |
My thoughts exactly. There were some suggestions for changes but I think getting this over the line firs tis a good step. Thanks @wiardvanrij, @matej-g |
* docs: Add instructions for configuring request logging Signed-off-by: Philip Gough <philip.p.gough@gmail.com> * docs: Update link to logging config and make docs Signed-off-by: Philip Gough <philip.p.gough@gmail.com> Signed-off-by: Nicholaswang <wzhever@gmail.com>
Fixes #4861
Changes
Verification