Skip to content

Commit

Permalink
modify config merger with acstor targets
Browse files Browse the repository at this point in the history
  • Loading branch information
shlokshah-dev committed Oct 1, 2024
1 parent 60c5006 commit 35eb938
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
48 changes: 48 additions & 0 deletions otelcollector/shared/configmap/mp/prometheus-config-merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,30 @@ func populateDefaultPrometheusConfig() {
}
}

if enabled, exists := os.LookupEnv("AZMON_PROMETHEUS_ACSTORCAPACITYPROVISIONER_SCRAPING_ENABLED"); exists && strings.ToLower(enabled) == "true" && currentControllerType == replicasetControllerType {
acstorCapacityProvisionerKeepListRegex, exists := regexHash["ACSTORCAPACITYPROVISONER_KEEP_LIST_REGEX"]
acstorCapacityProvisionerScrapeInterval, intervalExists := intervalHash["ACSTORCAPACITYPROVISIONER_SCRAPE_INTERVAL"]
if intervalExists {
UpdateScrapeIntervalConfig(acstorCapacityProvisionerDefaultFile, acstorCapacityProvisionerScrapeInterval)
}
if exists && acstorCapacityProvisionerKeepListRegex != "" {
AppendMetricRelabelConfig(acstorCapacityProvisionerDefaultFile, acstorCapacityProvisionerKeepListRegex)
}
defaultConfigs = append(defaultConfigs, acstorCapacityProvisionerDefaultFile)
}

if enabled, exists := os.LookupEnv("AZMON_PROMETHEUS_ACSTORMETRICSEXPORTER_SCRAPING_ENABLED"); exists && strings.ToLower(enabled) == "true" && currentControllerType == replicasetControllerType {
acstorMetricsExporterKeepListRegex, exists := regexHash["ACSTORMETRICSEXPORTER_KEEP_LIST_REGEX"]
acstorMetricsExporterScrapeInterval, intervalExists := intervalHash["ACSTORMETRICSEXPORTER_SCRAPE_INTERVAL"]
if intervalExists {
UpdateScrapeIntervalConfig(acstorMetricsExporterDefaultFile, acstorMetricsExporterScrapeInterval)
}
if exists && acstorMetricsExporterKeepListRegex != "" {
AppendMetricRelabelConfig(acstorMetricsExporterDefaultFile, acstorMetricsExporterKeepListRegex)
}
defaultConfigs = append(defaultConfigs, acstorMetricsExporterDefaultFile)
}

mergedDefaultConfigs = mergeDefaultScrapeConfigs(defaultConfigs)
// if mergedDefaultConfigs != nil {
// fmt.Printf("Merged default scrape targets: %v\n", mergedDefaultConfigs)
Expand Down Expand Up @@ -1099,6 +1123,30 @@ func populateDefaultPrometheusConfigWithOperator() {
}
}

if enabled, exists := os.LookupEnv("AZMON_PROMETHEUS_ACSTORCAPACITYPROVISIONER_SCRAPING_ENABLED"); exists && strings.ToLower(enabled) == "true" && currentControllerType == replicasetControllerType {
acstorCapacityProvisionerKeepListRegex, exists := regexHash["ACSTORCAPACITYPROVISONER_KEEP_LIST_REGEX"]
acstorCapacityProvisionerScrapeInterval, intervalExists := intervalHash["ACSTORCAPACITYPROVISIONER_SCRAPE_INTERVAL"]
if intervalExists {
UpdateScrapeIntervalConfig(acstorCapacityProvisionerDefaultFile, acstorCapacityProvisionerScrapeInterval)
}
if exists && acstorCapacityProvisionerKeepListRegex != "" {
AppendMetricRelabelConfig(acstorCapacityProvisionerDefaultFile, acstorCapacityProvisionerKeepListRegex)
}
defaultConfigs = append(defaultConfigs, acstorCapacityProvisionerDefaultFile)
}

if enabled, exists := os.LookupEnv("AZMON_PROMETHEUS_ACSTORMETRICSEXPORTER_SCRAPING_ENABLED"); exists && strings.ToLower(enabled) == "true" && currentControllerType == replicasetControllerType {
acstorMetricsExporterKeepListRegex, exists := regexHash["ACSTORMETRICSEXPORTER_KEEP_LIST_REGEX"]
acstorMetricsExporterScrapeInterval, intervalExists := intervalHash["ACSTORMETRICSEXPORTER_SCRAPE_INTERVAL"]
if intervalExists {
UpdateScrapeIntervalConfig(acstorMetricsExporterDefaultFile, acstorMetricsExporterScrapeInterval)
}
if exists && acstorMetricsExporterKeepListRegex != "" {
AppendMetricRelabelConfig(acstorMetricsExporterDefaultFile, acstorMetricsExporterKeepListRegex)
}
defaultConfigs = append(defaultConfigs, acstorMetricsExporterDefaultFile)
}

mergedDefaultConfigs = mergeDefaultScrapeConfigs(defaultConfigs)
// if mergedDefaultConfigs != nil {
// fmt.Printf("Merged default scrape targets: %v\n", mergedDefaultConfigs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func (fcl *FilesystemConfigLoader) SetDefaultScrapeSettings() (map[string]string
config["networkobservabilityHubble"] = "true"
config["networkobservabilityCilium"] = "true"
config["noDefaultsEnabled"] = "false"
config["acstor-capacity-provisioner"] = "false"
config["acstor-metrics-exporter"] = "false"
config["acstor-capacity-provisioner"] = "true"
config["acstor-metrics-exporter"] = "true"
return config, nil
}

Expand Down

0 comments on commit 35eb938

Please sign in to comment.