in otelcollector/prometheusreceiver/config.go [75:130]
func (cfg *PromConfig) Validate() error {
// Reject features that Prometheus supports but that the receiver doesn't support:
// See:
// * https://github.com/open-telemetry/opentelemetry-collector/issues/3863
// * https://github.com/open-telemetry/wg-prometheus/issues/3
unsupportedFeatures := make([]string, 0, 4)
if len(cfg.RemoteWriteConfigs) != 0 {
unsupportedFeatures = append(unsupportedFeatures, "remote_write")
}
if len(cfg.RemoteReadConfigs) != 0 {
unsupportedFeatures = append(unsupportedFeatures, "remote_read")
}
if len(cfg.RuleFiles) != 0 {
unsupportedFeatures = append(unsupportedFeatures, "rule_files")
}
if len(cfg.AlertingConfig.AlertRelabelConfigs) != 0 {
unsupportedFeatures = append(unsupportedFeatures, "alert_config.relabel_configs")
}
if len(cfg.AlertingConfig.AlertmanagerConfigs) != 0 {
unsupportedFeatures = append(unsupportedFeatures, "alert_config.alertmanagers")
}
if len(unsupportedFeatures) != 0 {
// Sort the values for deterministic error messages.
sort.Strings(unsupportedFeatures)
return fmt.Errorf("unsupported features:\n\t%s", strings.Join(unsupportedFeatures, "\n\t"))
}
scrapeConfigs, err := (*promconfig.Config)(cfg).GetScrapeConfigs()
if err != nil {
return err
}
// Since Prometheus 3.0, the scrape manager started to fail scrapes that don't have proper
// Content-Type headers, but they provided an extra configuration option to fallback to the
// previous behavior. We need to make sure that this option is set for all scrape configs
// to avoid introducing a breaking change.
for _, sc := range scrapeConfigs {
if sc.ScrapeFallbackProtocol == "" {
sc.ScrapeFallbackProtocol = promconfig.PrometheusText0_0_4
}
}
for _, sc := range scrapeConfigs {
if err := validateHTTPClientConfig(&sc.HTTPClientConfig); err != nil {
return err
}
for _, c := range sc.ServiceDiscoveryConfigs {
if c, ok := c.(*kubernetes.SDConfig); ok {
if err := validateHTTPClientConfig(&c.HTTPClientConfig); err != nil {
return err
}
}
}
}
return nil
}