diff --git a/cmd/kube-burner/kube-burner.go b/cmd/kube-burner/kube-burner.go index 0105fb19a..4087dcd39 100644 --- a/cmd/kube-burner/kube-burner.go +++ b/cmd/kube-burner/kube-burner.go @@ -134,7 +134,7 @@ func initCmd() *cobra.Command { cmd.Flags().StringVarP(&token, "token", "t", "", "Prometheus Bearer token") cmd.Flags().StringVar(&username, "username", "", "Prometheus username for authentication") cmd.Flags().StringVarP(&password, "password", "p", "", "Prometheus password for basic authentication") - cmd.Flags().StringVarP(&metricsProfile, "metrics-profile", "m", "metrics.yaml", "Metrics profile file or URL") + cmd.Flags().StringVarP(&metricsProfile, "metrics-profile", "m", "metrics.yml", "Metrics profile file or URL") cmd.Flags().StringVarP(&alertProfile, "alert-profile", "a", "", "Alert profile file or URL") cmd.Flags().BoolVar(&skipTLSVerify, "skip-tls-verify", true, "Verify prometheus TLS certificate") cmd.Flags().DurationVarP(&prometheusStep, "step", "s", 30*time.Second, "Prometheus step size") @@ -173,7 +173,7 @@ func destroyCmd() *cobra.Command { } func indexCmd() *cobra.Command { - var url, metricsProfile, configFile string + var url, metricsProfile, configFile, jobName string var start, end int64 var username, password, uuid, token string var skipTLSVerify bool @@ -204,7 +204,7 @@ func indexCmd() *cobra.Command { startTime := time.Unix(start, 0) endTime := time.Unix(end, 0) log.Infof("Indexing metrics with UUID %s", uuid) - if err := p.ScrapeMetrics(startTime, endTime, indexer); err != nil { + if err := p.ScrapeMetrics(startTime, endTime, indexer, jobName); err != nil { log.Error(err) } if config.ConfigSpec.GlobalConfig.WriteToFile && config.ConfigSpec.GlobalConfig.CreateTarball { @@ -220,12 +220,13 @@ func indexCmd() *cobra.Command { cmd.Flags().StringVarP(&token, "token", "t", "", "Prometheus Bearer token") cmd.Flags().StringVar(&username, "username", "", "Prometheus username for authentication") cmd.Flags().StringVarP(&password, "password", "p", "", "Prometheus password for basic authentication") - cmd.Flags().StringVarP(&metricsProfile, "metrics-profile", "m", "metrics.yaml", "Metrics profile file") + cmd.Flags().StringVarP(&metricsProfile, "metrics-profile", "m", "metrics.yml", "Metrics profile file") cmd.Flags().BoolVar(&skipTLSVerify, "skip-tls-verify", true, "Verify prometheus TLS certificate") cmd.Flags().DurationVarP(&prometheusStep, "step", "s", 30*time.Second, "Prometheus step size") cmd.Flags().Int64VarP(&start, "start", "", time.Now().Unix()-3600, "Epoch start time") cmd.Flags().Int64VarP(&end, "end", "", time.Now().Unix(), "Epoch end time") cmd.Flags().StringVarP(&configFile, "config", "c", "", "Config file path or URL") + cmd.Flags().StringVarP(&jobName, "job-name", "j", "kube-burner-indexing", "Indexing job name") cmd.MarkFlagRequired("prometheus-url") cmd.MarkFlagRequired("config") cmd.Flags().SortFlags = false diff --git a/pkg/prometheus/prometheus.go b/pkg/prometheus/prometheus.go index 5172a63d8..e81115b03 100644 --- a/pkg/prometheus/prometheus.go +++ b/pkg/prometheus/prometheus.go @@ -97,17 +97,16 @@ func (p *Prometheus) ReadProfile(metricsProfile string) error { } // ScrapeMetrics defined in the metrics profile from start to end -func (p *Prometheus) ScrapeMetrics(start, end time.Time, indexer *indexers.Indexer) error { - foo := []burner.Executor{ +func (p *Prometheus) ScrapeMetrics(start, end time.Time, indexer *indexers.Indexer, jobName string) error { + scraper := []burner.Executor{ { Start: start, End: end, Config: config.Job{ - Name: "kube-burner-indexing"}, + Name: jobName}, }, } - err := p.ScrapeJobsMetrics(foo, indexer) - return err + return p.ScrapeJobsMetrics(scraper, indexer) } // ScrapeJobsMetrics gets all prometheus metrics required and handles them @@ -162,7 +161,6 @@ func (p *Prometheus) ScrapeJobsMetrics(jobList []burner.Executor, indexer *index err = jsonEnc.Encode(metrics) if err != nil { log.Errorf("JSON encoding error: %s", err) - } } if config.ConfigSpec.GlobalConfig.IndexerConfig.Enabled { @@ -174,7 +172,6 @@ func (p *Prometheus) ScrapeJobsMetrics(jobList []burner.Executor, indexer *index } } return nil - } func (p *Prometheus) parseVector(metricName, query string, jobList []burner.Executor, value model.Value, metrics *[]interface{}) error {