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
Annotations: Clean up old annotations job #20815
Conversation
Hej @marefr any feedback here? |
Thanks for the PR, I will have a look at it. |
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.
After my revisions to this PR, it looks good to me. I need input from others on the team though.
// read dashboard settings | ||
annotations := iniFile.Section("annotations") | ||
DaysToKeepAnnotations = annotations.Key("days_to_keep").MustInt(60) | ||
if DaysToKeepAnnotations < 5 { |
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.
Any thoughts about this? Why not below 5? :)
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'm actually unsure about this too @bergquist - 5 was the minimum before my revising the PR.
|
||
[annotations] | ||
# Number of days to keep annotations (per alert). Default: 60, Minimum: 5 | ||
days_to_keep = 60 |
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'm torn about having this on by default.
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.
@bergquist I guess it should be turned off by default?
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 agree! At least now when it operates on all kinds of annotations. Maybe cleanup of alert annotations enabled per default would have made sense if it was the default from the beginning when alerting was introduced, but now it's sort of a breaking change so think we have to have it disabled per default.
#################################### Annotations ################## | ||
|
||
[annotations] | ||
# Number of days to keep annotations (per alert). Default: 60, Minimum: 5 |
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 comment says per alert but the SQL statement deletes all kinds of annotations. I think we should be clear about this and perhaps have different settings per kind of annotation.
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.
@bergquist Thanks for clarifying that 👍
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.
Some smaller things, see comments. In addition, configuration documentation needs to be updated as well.
@@ -145,6 +145,11 @@ func addAnnotationMig(mg *Migrator) { | |||
mg.AddMigration("Remove index org_id_epoch_epoch_end from annotation table", NewDropIndexMigration(table, &Index{ | |||
Cols: []string{"org_id", "epoch", "epoch_end"}, Type: IndexType, | |||
})) | |||
|
|||
// Increase size of tags field in annotation table |
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 would suggest moving this change to a separate PR with a referenced issue (existing or new one). Easier to keep each change separate and in case this would cause problem it's easier to revert only this instead of every change in this PR.
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.
Removing
daysToKeepAnnotations := 5 | ||
repo := SqlAnnotationRepo{} | ||
|
||
Convey("Deletion of expired annotations", t, func() { |
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.
New tests should use standard library for testing, see backend styleguide.
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.
@malish8632 Can you rewrite the new tests with the standard library as @marefr requests?
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.
hi @aknuds1 I'm going to take a stab at 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.
Thanks @malish8632!
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.
|
||
[annotations] | ||
# Number of days to keep annotations (per alert). Default: 60, Minimum: 5 | ||
days_to_keep = 60 |
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 agree! At least now when it operates on all kinds of annotations. Maybe cleanup of alert annotations enabled per default would have made sense if it was the default from the beginning when alerting was introduced, but now it's sort of a breaking change so think we have to have it disabled per default.
return nil | ||
} | ||
|
||
query = fmt.Sprintf("DELETE FROM annotation_tag WHERE annotation_id IN (?%s)", strings.Repeat(",?", |
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.
Are we comfortable/sure this will not lock the table and interfere with alerting?
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 was build with approach identical to how cleaning of dashboard_version table is done, which is currently the biggest in our internal system. Cleaning annotations is never being an issue for our MySQL server.
bus.AddHandler("sql", deleteExpiredAnnotations) | ||
} | ||
|
||
const MAX_EXPIRED_ANNOTATIONS_TO_DELETE = 900 |
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.
Why 900?
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'm also unsure about that @marefr. Maybe we should derive a sensible number?
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.
Initially tried 1000 but due to unit tests failures changed to 900
@aknuds1 For some reason grafana-docker-ubuntu-pr is failing... any pointers? |
Please merge with grafana master to fix build issues.
…On Fri, Feb 21, 2020, 19:11 Sergey Rustamov ***@***.***> wrote:
@aknuds1 <https://github.com/aknuds1> For some reason
grafana-docker-ubuntu-pr is failing... any pointers?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20815?email_source=notifications&email_token=AACEVV43MGWVJ72N2UR7TZDREAKO5A5CNFSM4JUFVHV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMTSXCI#issuecomment-589769609>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACEVVZ57J5CHW54JGUWMGLREAKO5ANCNFSM4JUFVHVQ>
.
|
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
b1b4c5d
to
c3594db
Compare
@aknuds1 Is there anything else you guys expecting from me? Thanks |
@malish8632 I requested new reviews from @bergquist and @marefr, let's see what they say. You also need to fix conflicts :) |
const MAX_EXPIRED_ANNOTATIONS_TO_DELETE = 900 | ||
|
||
func deleteExpiredAnnotations(cmd *m.DeleteExpiredAnnotationsCommand) error { | ||
return inTransaction(func(sess *DBSession) error { |
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.
Return this as inTransaction
performs all these SQL operations in one transaction. I dont think that's necessary. You can use withDbSession
instead to avoid transactions.
This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Looking forward to seeing this merged. |
This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Wow, stale bots suck. |
@tomtastic We've opened a new PR based on discussions in related issue |
What this PR does / why we need it:
This adds automatic clean up job to remove expired annotations and fixes existing issue #8224
Current number of days back to clean annotations is set to 60 and could be updated in defaults.ini settings.
This PR is not distinguishing between types of annotations. Any alerts or user created annotations treated the same.
This PR is also increasing the size of
annotation.tags
field as we encountered issues withVARCHAR(500)
as a limit on our instance.Which issue(s) this PR fixes:
Fixes #8224
Special notes for your reviewer: