Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support metrics scrape #2344

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jiuker
Copy link
Contributor

@jiuker jiuker commented Oct 18, 2024

feat: support metrics scrape
fix #2327
we just support /minio/v2/metrics/cluster before
now we can do more type for this
like

prometheusOperatorScrapeMetricsPath:
- /minio/v2/metrics/cluster
- /minio/v3/metrics/cluster
- /minio/v2/metrics/bucket

default is /minio/v2/metrics/cluster

@harshavardhana
Copy link
Member

We should add a way to scrape v3 metrics as well

@jiuker jiuker requested a review from shtripat October 18, 2024 07:43
@jiuker jiuker self-assigned this Oct 21, 2024
@cesnietor
Copy link
Contributor

@jiuker is there a way we can create tests for this? since this is a new feature? like an integration test? Thanks.

jiuker added 4 commits December 9, 2024 11:51
@pjuarezd pjuarezd force-pushed the feat-support-metrics-scrope branch from b38e1b6 to 982f5d4 Compare December 9, 2024 19:51
@@ -474,6 +476,13 @@ spec:
required:
- path
type: object
image:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this, and other similar changes, to the tenant crd needed?

Comment on lines +239 to +242
if !reflect.DeepEqual(scrapeConfigs, exceptedScrapeConfigs) {
klog.Infof("Deleting MinIO tenant Prometheus scrape config")
// Delete the config
newScrapeConfigs := append(scrapeConfigs[:scIndex], scrapeConfigs[scIndex+1:]...)
// Update the secret
scrapeCfgYaml, err := yaml.Marshal(newScrapeConfigs)
scrapeCfgYaml, err := yaml.Marshal(exceptedScrapeConfigs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflectDeepEqual will always return false due to the implementation of GetPrometheusConfig. This will trigger multiple unnecessary secret recreation.

Please consider the following option instead:

// add new scrape configs
    exceptedScrapeConfigs = append(exceptedScrapeConfigs, promCfg.ScrapeConfigs...)
    // compare scrape configs excluding bearer token to avoid continuous updates
    updateScrapeConfig := false
    if len(scrapeConfigs) != len(exceptedScrapeConfigs) {
      updateScrapeConfig = true
    } else {
      for i, _ := range scrapeConfigs {
        if scrapeConfigs[i].JobName != exceptedScrapeConfigs[i].JobName ||
          scrapeConfigs[i].MetricsPath != exceptedScrapeConfigs[i].MetricsPath ||
          scrapeConfigs[i].Scheme != exceptedScrapeConfigs[i].Scheme ||
          !reflect.DeepEqual(scrapeConfigs[i].TLSConfig, exceptedScrapeConfigs[i].TLSConfig) ||
          !reflect.DeepEqual(scrapeConfigs[i].StaticConfigs, exceptedScrapeConfigs[i].StaticConfigs) {
          updateScrapeConfig = true
          break
        }
      }
    }
    if updateScrapeConfig {
      klog.Infof("Adding MinIO tenant Prometheus scrape config")
      scrapeConfigs = exceptedScrapeConfigs
      scrapeCfgYaml, err := yaml.Marshal(scrapeConfigs)
      if err != nil {
        return err
      }
      secret.Data[miniov2.PrometheusAddlScrapeConfigKey] = scrapeCfgYaml
      _, err = c.kubeClientSet.CoreV1().Secrets(ns).Update(ctx, secret, metav1.UpdateOptions{})
      if err != nil {
        return err
      }
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take a look @jiuker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: expose more Prometheus metrics than just /minio/v2/metrics/cluster
5 participants