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

fix(cli): add cleanup pattern metrics cli key #1019

Merged
merged 4 commits into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ var plotting = flag.Bool("plotting", false, "enable images in all notifications"
var removeSubscriptions = flag.String("remove-subscriptions", "", "Remove given subscriptions separated by semicolons.")

var (
cleanupUsers = flag.Bool("cleanup-users", false, "Disable/delete contacts and subscriptions of missing users")
cleanupLastChecks = flag.Bool("cleanup-last-checks", false, "Delete abandoned triggers last checks.")
cleanupTags = flag.Bool("cleanup-tags", false, "Delete abandoned tags.")
cleanupMetrics = flag.Bool("cleanup-metrics", false, "Delete outdated metrics.")
cleanupFutureMetrics = flag.Bool("cleanup-future-metrics", false, "Delete metrics with future timestamps.")
cleanupRetentions = flag.Bool("cleanup-retentions", false, "Delete abandoned retentions.")
userDel = flag.String("user-del", "", "Delete all contacts and subscriptions for a user")
fromUser = flag.String("from-user", "", "Transfer subscriptions and contacts from user.")
toUser = flag.String("to-user", "", "Transfer subscriptions and contacts to user.")
cleanupUsers = flag.Bool("cleanup-users", false, "Disable/delete contacts and subscriptions of missing users")
cleanupLastChecks = flag.Bool("cleanup-last-checks", false, "Delete abandoned triggers last checks.")
cleanupTags = flag.Bool("cleanup-tags", false, "Delete abandoned tags.")
cleanupMetrics = flag.Bool("cleanup-metrics", false, "Delete outdated metrics.")
cleanupPatternMetrics = flag.Bool("cleanup-pattern-metrics", false, "Delete outdated pattern metrics.")
cleanupFutureMetrics = flag.Bool("cleanup-future-metrics", false, "Delete metrics with future timestamps.")
cleanupRetentions = flag.Bool("cleanup-retentions", false, "Delete abandoned retentions.")
userDel = flag.String("user-del", "", "Delete all contacts and subscriptions for a user")
fromUser = flag.String("from-user", "", "Transfer subscriptions and contacts from user.")
toUser = flag.String("to-user", "", "Transfer subscriptions and contacts to user.")
)

var (
Expand Down Expand Up @@ -239,6 +240,14 @@ func main() { //nolint
Msg("Failed to cleanup outdated metrics")
}

log.Info().Msg("Cleanup of outdated metrics finished")
}

if *cleanupPatternMetrics {
log := logger.String(moira.LogFieldNameContext, "cleanup-pattern-metrics")

log.Info().Msg("Cleanup of outdated pattern metrics started")

count, err := handleCleanUpOutdatedPatternMetrics(database)
if err != nil {
log.Error().
Expand All @@ -250,7 +259,7 @@ func main() { //nolint
Int64("deleted_pattern_metrics", count).
Msg("Cleaned up outdated pattern metrics")

log.Info().Msg("Cleanup of outdated metrics finished")
log.Info().Msg("Cleanup of outdated pattern metrics finished")
}

if *cleanupFutureMetrics {
Expand Down
Loading