diff --git a/pkg/controller/prometheus.go b/pkg/controller/prometheus.go index 67f9d9c0afb..c5d72bceaec 100644 --- a/pkg/controller/prometheus.go +++ b/pkg/controller/prometheus.go @@ -18,6 +18,7 @@ import ( "context" "errors" "reflect" + "strings" promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" promv1alpha1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1" @@ -169,7 +170,7 @@ func (c *Controller) checkAndCreatePrometheusAddlConfig(ctx context.Context, ten } // get other scrape configs for _, sc := range scrapeConfigs { - if sc.JobName != tenant.PrometheusOperatorAddlConfigJobName() { + if !strings.HasPrefix(sc.JobName, tenant.PrometheusOperatorAddlConfigJobName()) { exceptedScrapeConfigs = append(exceptedScrapeConfigs, sc) } } @@ -231,7 +232,7 @@ func (c *Controller) deletePrometheusAddlConfig(ctx context.Context, tenant *min return err } for _, sc := range scrapeConfigs { - if sc.JobName != tenant.PrometheusOperatorAddlConfigJobName() { + if !strings.HasPrefix(sc.JobName, tenant.PrometheusOperatorAddlConfigJobName()) { exceptedScrapeConfigs = append(exceptedScrapeConfigs, sc) } } diff --git a/pkg/resources/configmaps/prometheus.go b/pkg/resources/configmaps/prometheus.go index ed3f73da9ba..20aed0bba80 100644 --- a/pkg/resources/configmaps/prometheus.go +++ b/pkg/resources/configmaps/prometheus.go @@ -87,9 +87,9 @@ func GetPrometheusConfig(t *miniov2.Tenant, accessKey, secretKey string) *Promet t.Spec.PrometheusOperatorScrapeMetricsPath = []string{"/minio/v2/metrics/cluster"} } - for _, scrape := range t.Spec.PrometheusOperatorScrapeMetricsPath { + for index, scrape := range t.Spec.PrometheusOperatorScrapeMetricsPath { promConfig.ScrapeConfigs = append(promConfig.ScrapeConfigs, ScrapeConfig{ - JobName: t.PrometheusConfigJobName(), + JobName: fmt.Sprintf("%s-%d", t.PrometheusOperatorAddlConfigJobName(), index), BearerToken: bearerToken, MetricsPath: scrape, Scheme: minioScheme,