-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Enable toggling request logging on/off for different query types #7562
Conversation
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@druid.apache.org list. Thank you for your contributions. |
This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
@gianm @Caroline1000 Any interest in reviving this PR to address the related issue regarding the logging here? |
+1 for reviving. Having the |
This pull request/issue is no longer marked as stale. |
Reopened!! |
docs/content/configuration/index.md
Outdated
@@ -316,6 +316,7 @@ All processes that can serve queries can also log the query requests they see. B | |||
|Property|Description|Default| | |||
|--------|-----------|-------| | |||
|`druid.request.logging.type`|Choices: noop, file, emitter, slf4j, filtered, composing, switching. How to log every query request.|[required to configure request logging]| | |||
| `druid.request.logging.logSegmentMetadataQueries`| Boolean indicating if SegmentMetadata Queries should be logged by the Request Logger.| true| |
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 the way this property behaves is good, but it would be better inside FilteredRequestLogger. That way, it's composable, rather than needing to be implemented inside each and every RequestLogger.
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 the overall approach is still unnecessarily specific. It would be more generic if a config accepts a list of query types which shouldn't be logged.
|
||
public FilteredRequestLogger(RequestLogger logger, long queryTimeThresholdMs, long sqlQueryTimeThresholdMs) | ||
public FilteredRequestLogger(RequestLogger logger, long queryTimeThresholdMs, long sqlQueryTimeThresholdMs, |
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.
According to Druid style, should chop down the list of params:
public FilteredRequestLogger(RequestLogger logger, long queryTimeThresholdMs, long sqlQueryTimeThresholdMs, | |
public FilteredRequestLogger( | |
RequestLogger logger, | |
long queryTimeThresholdMs, | |
long sqlQueryTimeThresholdMs, | |
boolean logSegmentMetadataQueries | |
) | |
{ |
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.
You might want to look into using spotless as a pre-push hook so that you don't have to catch styling issues in code review. It will automatically re-format the code according to a provided style guide
https://github.com/diffplug/spotless/tree/master/plugin-maven#applying-to-java-source
(long time lurker) Sorry if this is a redundant suggestion and you already have another tool that does similar stuff
@leventov That sounds like a good idea to me. How would you propose handling erroneous entries by users? Hard failure, Ignore with a warning log, other? |
@capistrant I think hard failure would be in line with the existing code in Druid, e. g. in |
However, according to the policy proposed by @drcrallen here: #8083 (comment) (and which I think is reasonable), there should be only a warning, not a hard failure. |
In line with #8083 (comment) I agree it should be a warning. If my understanding is correct, miss-configuration in such a scenario would bring the behavior closer to the "default" behavior (i.e. worst case is it is reconciled to behave no different than if it weren't configured). |
Thanks all for the tips and info! I'll be cleaning this up this week following all the feedback |
docs/content/configuration/index.md
Outdated
@@ -379,6 +379,7 @@ For native query, only request logs where query/time is above the threshold are | |||
|--------|-----------|-------| | |||
|`druid.request.logging.queryTimeThresholdMs`|Threshold value for query/time in milliseconds.|0 i.e no filtering| | |||
|`druid.request.logging.sqlQueryTimeThresholdMs`|Threshold value for sqlQuery/time in milliseconds.|0 i.e no filtering| | |||
|`druid.request.logging.queryTypeBlacklist` | List of Druid query types to exclude from request logs. Query types are defined as string objects in the Query interface found in Query.java. Mispelled query types will be ignored. Example to ignore scan and timeBoundary queries: ["scan", "timeBoundary"]| []| |
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.
queryTypeBlacklist
sounds a little intimidating. I would say "mutedQueryTypes".
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 suggest the description:
```suggestion
|`druid.request.logging.mutedQueryTypes` | Query requests of these types are not logged. Query types are defined as string objects corresponding to the "queryType" value for the specified query in the Druid's [native JSON query API](http://druid.apache.org/docs/latest/querying/querying.html). Misspelled query types will be ignored. Example to ignore scan and timeBoundary queries: ["scan", "timeBoundary"]| []|
@@ -58,7 +58,8 @@ | |||
@Override | |||
public RequestLogger get() | |||
{ | |||
FileRequestLogger logger = new FileRequestLogger(jsonMapper, factory.create(1, "RequestLogger-%s"), dir, filePattern); | |||
FileRequestLogger logger = new FileRequestLogger(jsonMapper, factory.create(1, "RequestLogger-%s"), dir, | |||
filePattern); |
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.
Please chop down all arguments (each on its own line) if they don't fit a line.
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.
got it. I've got to stop forgetting about that one, thanks for the comment
|
||
public FilteredRequestLogger(RequestLogger logger, long queryTimeThresholdMs, long sqlQueryTimeThresholdMs) | ||
public FilteredRequestLogger(RequestLogger logger, |
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.
Please chop down params: #7562 (comment)
@@ -106,6 +113,10 @@ public void testNotFilterAboveThreshold() throws IOException | |||
EasyMock.expect(nativeRequestLogLine.getQueryStats()) | |||
.andReturn(new QueryStats(ImmutableMap.of("query/time", 1000))) | |||
.once(); | |||
EasyMock.expect(nativeRequestLogLine.getQuery()) | |||
.andReturn(new SegmentMetadataQuery(new LegacyDataSource("foo"), |
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.
Please extract new SegmentMetadataQuery(...)
as a variable.
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.
Wasn't sure if I should do one final class variable or two local variables (one per method). Went with the former, but would be easy to change to something else if my choice happens to be considered a bad pattern in Java
@@ -114,6 +125,10 @@ public void testNotFilterAboveThreshold() throws IOException | |||
EasyMock.expect(sqlRequestLogLine.getQueryStats()) | |||
.andReturn(new QueryStats(ImmutableMap.of("sqlQuery/time", 2000))) | |||
.once(); | |||
EasyMock.expect(sqlRequestLogLine.getQuery()) | |||
.andReturn(new SegmentMetadataQuery(new LegacyDataSource("foo"), |
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
.andReturn(new QueryStats(ImmutableMap.of("query/time", 10000))) | ||
.once(); | ||
EasyMock.expect(nativeRequestLogLine.getQuery()) | ||
.andReturn(new SegmentMetadataQuery(new LegacyDataSource("foo"), |
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
.andReturn(new QueryStats(ImmutableMap.of("sqlQuery/time", 10000))) | ||
.once(); | ||
EasyMock.expect(sqlRequestLogLine.getQuery()) | ||
.andReturn(new SegmentMetadataQuery(new LegacyDataSource("foo"), |
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
I'm not sure how to interpret the TeamCity Failure. I'm looking in the errors in the report but don't see any of the files I changed in the files listed as error. |
I'm not sure either. I triggered the job to run again, in case it was something weird with that run. |
If you haven't merged master into your branch recently, sometimes that helps. You could try that if TC bombs out again. |
Thanks @gianm, restarting it seemed to do the trick 👍 |
FileRequestLogger logger = new FileRequestLogger(jsonMapper, factory.create(1, "RequestLogger-%s"), dir, | ||
filePattern); | ||
FileRequestLogger logger = new FileRequestLogger( | ||
jsonMapper, |
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.
In Druid, the wrapping indentation is 4, not 8 spaces. Please also fix other places in this PR.
@@ -106,6 +123,9 @@ public void testNotFilterAboveThreshold() throws IOException | |||
EasyMock.expect(nativeRequestLogLine.getQueryStats()) | |||
.andReturn(new QueryStats(ImmutableMap.of("query/time", 1000))) | |||
.once(); | |||
EasyMock.expect(nativeRequestLogLine.getQuery()) |
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.
@leventov Does that wrapping indentation of 4 standard include lines such as these 3? I see that the lines above and below are had been using 8.
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.
No. Here, the alignment is on the dot. It's a coincidence that "EasyMock" is 8 characters long.
@capistrant thanks for following through! |
@leventov Thanks for the review and guidance for this PR! I'll work to get my editor better set up to comply with Druid style rules and have some automated checks client side so there is less back and forth regarding those tedious errors in the future 👍 |
thank you @capistrant ! 🎉 |
Relates to #7115 and #5320
In reference to @gianm comment in #5320: I held off on making this a more involved enhancement that would allow ignoring only internal SegmentMetadata queries as opposed to all SegmentMetadata queries because I wasn't sure of the value add from doing that versus a blanket ignore of this type. I am certainly open to revisiting that and making this more than an on/off switch. (something like
druid.request.logging.logSegmentMetadataQueries
with the optionsall, none, internal_only, external_only
that then leverages the identity in the query -- defaulting to logging all SegmentMetadata queries in clusters not using security and the config is not set to none)