Skip to content

Commit

Permalink
Indexing job name (kube-burner#137)
Browse files Browse the repository at this point in the history
* Replace yaml by yml in defaults

Signed-off-by: Raul Sevilla <[email protected]>

* Indexing jobName

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Oct 20, 2021
1 parent e99afeb commit 673aae3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 5 additions & 4 deletions cmd/kube-burner/kube-burner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
11 changes: 4 additions & 7 deletions pkg/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 673aae3

Please sign in to comment.