bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/bosun/database/test/util/purge_search_data.go (about)

     1  package main
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  
     7  	"bosun.org/cmd/bosun/database"
     8  )
     9  
    10  // USAGE: go run purge_search_data.go -r redishost:6379 -m metricIWantToClear
    11  // use -n to see what would get deleted, without changing any data
    12  
    13  var redis = flag.String("r", "", "redis host:port")
    14  var metric = flag.String("m", "", "metric to purge")
    15  var noop = flag.Bool("n", false, "only print commands, don't run.")
    16  
    17  func main() {
    18  	flag.Parse()
    19  	if *redis == "" || *metric == "" {
    20  		flag.PrintDefaults()
    21  		return
    22  	}
    23  	db := database.NewDataAccess([]string{*redis}, true, "", 0, "").(interface {
    24  		PurgeSearchData(string, bool) error
    25  	})
    26  	err := db.PurgeSearchData(*metric, *noop)
    27  	fmt.Println(err)
    28  }