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

ref(abuse) Add more predefined querylog queries #3489

Merged
merged 1 commit into from
Dec 9, 2022

Conversation

evanh
Copy link
Member

@evanh evanh commented Dec 8, 2022

Add two new queries to help narrow down with referrers might be causing the
abuse. To use these queries you should already know which cluster is
experiencing the abuse, and at what time the abuse started.

The idea behind the queries is: take half an hour before the abuse started, and
half an hour after. Compare the referrers between those two time periods, and
surface the ones that had the highest percentage change from before to after.

The purpose of these is not to automatically find the smoking gun, but to at
least remove some of the noise and show some actionable signal that can be
followed up on to confirm if one of the referrers actually is the source of
the problem.

I tested these queries on some known cases of abuse, and they did surface the
referrers that turned out to be the problem.

Add two new queries to help narrow down with referrers might be causing the
abuse. To use these queries you should already know which cluster is
experiencing the abuse, and at what time the abuse started.

The idea behind the queries is: take half an hour before the abuse started, and
half an hour after. Compare the referrers between those two time periods, and
surface the ones that had the highest percentage change from before to after.

The purpose of these is not to automatically find the smoking gun, but to at
least remove some of the noise and show some actionable signal that can be
followed up on to confirm if one of the referrers actually is the source of
the problem.

I tested these queries on some known cases of abuse, and they did surface the
referrers that turned out to be the problem.
@evanh evanh requested a review from a team as a code owner December 8, 2022 21:38
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2022

Codecov Report

Base: 91.66% // Head: 91.66% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (947e6c0) compared to base (2f6c76e).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3489   +/-   ##
=======================================
  Coverage   91.66%   91.66%           
=======================================
  Files         715      715           
  Lines       33472    33476    +4     
=======================================
+ Hits        30681    30685    +4     
  Misses       2791     2791           
Impacted Files Coverage Δ
...ba/admin/clickhouse/predefined_querylog_queries.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@volokluev volokluev left a comment

Choose a reason for hiding this comment

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

cool!

Comment on lines +126 to +127
WHERE timestamp >= toDateTime('2022-12-07T21:55:00')
AND timestamp <= toDateTime('2022-12-07T22:20:00')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
WHERE timestamp >= toDateTime('2022-12-07T21:55:00')
AND timestamp <= toDateTime('2022-12-07T22:20:00')
WHERE timestamp >= toDateTime(<time_str_after_abuse>)
AND timestamp <= toDateTime(<time_str_after_abuse + 30 mins)

Copy link
Member

Choose a reason for hiding this comment

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

Making these explicit descriptive parameters may be easier for the user

Copy link
Member

Choose a reason for hiding this comment

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

I filed a ticket to make this a feature in the tool, but I do think this is still an improvement

Copy link
Member Author

Choose a reason for hiding this comment

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

I deliberately left these like this, since I find it easier when I have an actual example to edit. Otherwise I have to remind myself of the exact date format Clickhouse expects.

I would like to have our tools ultimately work using parameters though, in a similar way to how saved queries work on Redash. Users fill out a form with the values they want and we template them into the query.

Copy link
Member

Choose a reason for hiding this comment

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

up to you, PR is approved though. Thanks for adding this query!

Comment on lines +134 to +135
WHERE timestamp >= toDateTime('2022-12-07T21:24:00')
AND timestamp <= toDateTime('2022-12-07T21:54:00')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
WHERE timestamp >= toDateTime('2022-12-07T21:24:00')
AND timestamp <= toDateTime('2022-12-07T21:54:00')
WHERE timestamp >= toDateTime(<time_str_before_abuse>)
AND timestamp <= toDateTime(<time_str_before_abuse + 30mins>)

@evanh evanh merged commit 86d3efb into master Dec 9, 2022
@evanh evanh deleted the evanh/fix/add-more-predefined-queries branch December 9, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants