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

Document request logging configuration #4934

Merged
merged 2 commits into from Feb 9, 2022

Conversation

philipgough
Copy link
Contributor

Fixes #4861

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Verification

@philipgough philipgough force-pushed the query-log branch 2 times, most recently from 6a3bde2 to 04338a5 Compare December 8, 2021 17:22
@bwplotka
Copy link
Member

bwplotka commented Dec 8, 2021

You might need to run make docs to auto-gen docs (:

http:
config:
- path: /api/v1/query
port: 10904
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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? 🤔

Copy link
Contributor Author

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.

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?

Copy link
Contributor Author

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.

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!

Copy link
Contributor Author

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.

Copy link
Collaborator

@matej-g matej-g left a 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.

docs/logging.md Outdated Show resolved Hide resolved
http:
config:
- path: /api/v1/query
port: 10904
Copy link
Collaborator

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? 🤔

Copy link
Collaborator

@matej-g matej-g left a 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

docs/logging.md Outdated Show resolved Hide resolved

### Options

Valid `level` for `options` should be one of `INFO`, `WARNING`, `ERROR` or `DEBUG`.
Copy link
Collaborator

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? 🤔

Copy link
Contributor Author

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 :)

Copy link
Collaborator

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!

matej-g
matej-g previously approved these changes Jan 21, 2022
Copy link
Collaborator

@matej-g matej-g left a 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!

@dwilliams782
Copy link

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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wiardvanrij
Copy link
Member

Hi thanks. Let's get this merged. Could you rebase from main as we've changed some tests and these are now missing?

@philipgough
Copy link
Contributor Author

@wiardvanrij - rebased - docs check seems to be failing but not sure that it is related if you wouldn't mind running the check again?

@wiardvanrij
Copy link
Member

@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.

@pull-request-size pull-request-size bot added size/XL and removed size/L labels Feb 8, 2022
Signed-off-by: Philip Gough <philip.p.gough@gmail.com>
@philipgough
Copy link
Contributor Author

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.

Noted, I ran make docs and it did indeed produce a diff but it feels like it is incorrect regardless..I've committed the results so lets see what the check shows

@wiardvanrij
Copy link
Member

wiardvanrij commented Feb 8, 2022

@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?
Ah, --- ignore this, what @matej-g said :x

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 )

@matej-g
Copy link
Collaborator

matej-g commented Feb 8, 2022

Noted, I ran make docs and it did indeed produce a diff but it feels like it is incorrect regardless..I've committed the results so lets see what the check shows

I think you need to run make check-docs, as this is what the CI check is using, as it does a couple of extra steps, including removing white noise.

@philipgough
Copy link
Contributor Author

philipgough commented Feb 8, 2022

@matej-g - will try that, although the output of the github action is run make docs and commit changes

solution seems to have been brew install gsed

Signed-off-by: Philip Gough <philip.p.gough@gmail.com>
Copy link
Collaborator

@matej-g matej-g left a 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? 🙂

@wiardvanrij
Copy link
Member

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.

@wiardvanrij wiardvanrij enabled auto-merge (squash) February 9, 2022 17:54
@wiardvanrij wiardvanrij merged commit c038534 into thanos-io:main Feb 9, 2022
@philipgough
Copy link
Contributor Author

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

Nicholaswang pushed a commit to Nicholaswang/thanos that referenced this pull request Mar 6, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Document the query logging feature better
6 participants