(cmd *cobra.Command, t string)
| 67 | } |
| 68 | |
| 69 | func prometheusCache(cmd *cobra.Command, t string) error { |
| 70 | conn := getConn(cmd) |
| 71 | if conn == nil { |
| 72 | return fmt.Errorf("connect to server via grpc error") |
| 73 | } |
| 74 | defer conn.Close() |
| 75 | |
| 76 | var prometheusType controller.PrometheusCacheType |
| 77 | switch t { |
| 78 | case "all": |
| 79 | prometheusType = controller.PrometheusCacheType_ALL |
| 80 | case "metric-name": |
| 81 | prometheusType = controller.PrometheusCacheType_METRIC_NAME |
| 82 | case "label-name": |
| 83 | prometheusType = controller.PrometheusCacheType_LABEL_NAME |
| 84 | case "label-value": |
| 85 | prometheusType = controller.PrometheusCacheType_LABEL_VALUE |
| 86 | case "metric-and-app-layout": |
| 87 | prometheusType = controller.PrometheusCacheType_METRIC_AND_APP_LABEL_LAYOUT |
| 88 | case "target": |
| 89 | prometheusType = controller.PrometheusCacheType_TARGET |
| 90 | case "label": |
| 91 | prometheusType = controller.PrometheusCacheType_LABEL |
| 92 | case "metric-label": |
| 93 | prometheusType = controller.PrometheusCacheType_METRIC_LABEL |
| 94 | case "metric-target": |
| 95 | prometheusType = controller.PrometheusCacheType_METRIC_TARGET |
| 96 | |
| 97 | default: |
| 98 | return fmt.Errorf("type(%s) is not supported, please use all | metric-name | label-name | label-value | "+ |
| 99 | "metric-and-app-layout | target | label | metric-label | metric-target", t) |
| 100 | } |
| 101 | |
| 102 | c := controller.NewPrometheusDebugClient(conn) |
| 103 | reqData := &controller.PrometheusCacheRequest{ |
| 104 | Type: &prometheusType, |
| 105 | } |
| 106 | resp, err := c.DebugPrometheusCache(context.Background(), reqData) |
| 107 | if err != nil { |
| 108 | return err |
| 109 | } |
| 110 | |
| 111 | fmt.Printf("%s\n", resp.GetContent()) |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | func prometheusClear(cmd *cobra.Command, expiredAt string) { |
| 116 | server := common.GetServerInfo(cmd) |
no test coverage detected