-
Notifications
You must be signed in to change notification settings - Fork 455
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
base: master
Are you sure you want to change the base?
Conversation
We should add a way to scrape v3 metrics as well |
@jiuker is there a way we can create tests for this? since this is a new feature? like an integration test? Thanks. |
feat: support metrics scrape
b38e1b6
to
982f5d4
Compare
@@ -474,6 +476,13 @@ spec: | |||
required: | |||
- path | |||
type: object | |||
image: |
There was a problem hiding this comment.
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?
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) |
There was a problem hiding this comment.
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
}
}
There was a problem hiding this comment.
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
feat: support metrics scrape
fix #2327
we just support
/minio/v2/metrics/cluster
beforenow we can do more type for this
like
default is
/minio/v2/metrics/cluster