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
Clean up job for old annotations. #8224
Comments
yes, there needs to be some retention config & cleanup scheduling |
This should be implemented the same way as #9671 But I don't think its as easy to find a good default value. So I suggest |
That sounds like a good plan. Tricky with a good default value |
Thinking a little bit more about this issue. We need to solve two problems.
Both should be triggered from https://github.com/grafana/grafana/blob/master/pkg/services/cleanup/cleanup.go#L48 |
This would be extremely helpful since I just found out that my most of them are those second mentioned without
Thank's for looking into this! |
Notes on what I think we need for complete annotations cleanup: Annotations Cleanup Feature:
Job getting counts for cleanup can also record counts as metrics. Other notes:
|
@kylebrandt Good, write up. I wonder if we can slim down the requirements for this feature to only delete any annotations if they are older the X (off by default). I can see many different configurable ways to delete annotations
I'm not sure we want to provide configuration for all those options. I know I contradict my previous comments but thinking more about this we need so many different ways to decide what to delete to make it a good feature. Delete jobs like this is very scriptable in case someone have special requirements. |
I tend to agree. Still, alert annotations are always created by the system and would make sense to be able to automatically delete those older than X. I think manually created annotations are being used to mark for example outages and could be important to keep those intact even though their older than X days. My suggestion would be to make a difference between alert and non-alert annotations.
Scripting in database yes, but currently our API's are not very convenient to use since you first need to figure out which annotation identifiers you want to delete. Ref https://grafana.com/docs/grafana/latest/http_api/annotations/#delete-annotation-by-id |
I think greater than count in addition to time could be important for keeping hosted grafana stable. |
The code complexity for dealing with all those filters will be fairly small. I'm more worried about creating too many new settings that can confuse the user. |
Based on what we said so far. I think that the cleanup job should support both max-age and max count but require the administrator to opt-in for each kind of annotation. Ex Alert/API/Human. API meaning that there is no dashboard_id associated with the annotations. I'm not sure those are good descriptions of what kind of annotation they would include in the cleanup but I don’t have a better suggestion. The settings could look something like this: [annotations]
max_annotations_to_keep = 50000 # 0 meaning disabled
max_age = 50d # 0 meaning disabled
prune_alert_annotations = true # false by default
prune_api_annotations = true # false by default
prune_human_made_annotations = true # false by default I’m not sure how we should deal with tags since it’s a global table and not only related to annotations. To safely delete items from that table we need to check if it’s used in any other places. I think this problem we should solve separately. |
@bergquist given we have three kinds of annotations or two depending how you see it:
Was thinking something along these lines with a section per type.
Maybe make more sense to move the alerting annotation settings to alerting settings instead? e.g.
|
Adding annotations from a dashboard will associate it with the dashboard. Even if you use tags. Annotations without dashboard id can only be created using the API. Otherwise, I like your suggestion for dividing it up. Moving alert annotations to a separate section seems like a good idea. They should be stored somewhere else anyway. |
Alert execution engine is one of the useful functionality that would potentially be used extensively. The "events" are persisted as annotations. This can potentially grow larger as the adoption increases. Do we see any potential issues with regards to retention/maintenance etc?
Just opening a placeholder issues to discuss and brainstorm on this.
The text was updated successfully, but these errors were encountered: