diff --git a/config/config.go b/config/config.go index d61a1457e7..3eb2c17602 100644 --- a/config/config.go +++ b/config/config.go @@ -172,6 +172,8 @@ var ( ScrapeProtocols: DefaultScrapeProtocols, ConvertClassicHistogramsToNHCB: false, AlwaysScrapeClassicHistograms: false, + MetricNameValidationScheme: UTF8ValidationConfig, + MetricNameEscapingScheme: model.AllowUTF8, } DefaultRuntimeConfig = RuntimeConfig{ @@ -179,7 +181,10 @@ var ( GoGC: getGoGC(), } - // DefaultScrapeConfig is the default scrape configuration. + // DefaultScrapeConfig is the default scrape configuration. Users of this + // default MUST call Validate() on the config after creation, even if it's + // used unaltered, to check for parameter correctness and fill out default + // values that can't be set inline in this declaration. DefaultScrapeConfig = ScrapeConfig{ // ScrapeTimeout, ScrapeInterval, ScrapeProtocols, AlwaysScrapeClassicHistograms, and ConvertClassicHistogramsToNHCB default to the configured globals. MetricsPath: "/metrics", @@ -940,6 +945,12 @@ func (c *ScrapeConfig) MarshalYAML() (interface{}, error) { // ToValidationScheme returns the validation scheme for the given string config value. func ToValidationScheme(s string) (validationScheme model.ValidationScheme, err error) { switch s { + case "": + // This is a workaround for third party exporters that don't set the validation scheme. + if DefaultGlobalConfig.MetricNameValidationScheme == "" { + return model.UTF8Validation, errors.New("global metric name validation scheme is not set") + } + return ToValidationScheme(DefaultGlobalConfig.MetricNameValidationScheme) case UTF8ValidationConfig: validationScheme = model.UTF8Validation case LegacyValidationConfig: @@ -951,6 +962,21 @@ func ToValidationScheme(s string) (validationScheme model.ValidationScheme, err return validationScheme, nil } +// ToEscapingScheme wraps the equivalent common library function with the +// desired default behavior based on the given validation scheme. This is a +// workaround for third party exporters that don't set the escaping scheme. +func ToEscapingScheme(s string, v model.ValidationScheme) (model.EscapingScheme, error) { + if s == "" { + switch v { + case model.UTF8Validation: + return model.NoEscaping, nil + case model.LegacyValidation: + return model.UnderscoreEscaping, nil + } + } + return model.ToEscapingScheme(s) +} + // ConvertClassicHistogramsToNHCBEnabled returns whether to convert classic histograms to NHCB. func (c *ScrapeConfig) ConvertClassicHistogramsToNHCBEnabled() bool { return c.ConvertClassicHistogramsToNHCB != nil && *c.ConvertClassicHistogramsToNHCB diff --git a/config/config_test.go b/config/config_test.go index 43ea2fcd48..afa46bf84c 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -223,8 +223,8 @@ var expectedConf = &Config{ ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFallbackProtocol: PrometheusText0_0_4, ScrapeFailureLogFile: "testdata/fail_prom.log", - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -340,8 +340,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: 210, ScrapeProtocols: []ScrapeProtocol{PrometheusText0_0_4}, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -442,8 +442,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -502,8 +502,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -540,8 +540,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -584,8 +584,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -628,8 +628,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -662,8 +662,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -704,8 +704,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -743,8 +743,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -789,8 +789,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -825,8 +825,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -864,8 +864,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -896,8 +896,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -931,8 +931,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -966,8 +966,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1001,8 +1001,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1033,8 +1033,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1073,8 +1073,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1112,8 +1112,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1148,8 +1148,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1183,8 +1183,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1222,8 +1222,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1264,8 +1264,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1325,8 +1325,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1357,8 +1357,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1400,8 +1400,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1449,8 +1449,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1488,8 +1488,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1528,8 +1528,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1563,8 +1563,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), @@ -1600,8 +1600,8 @@ var expectedConf = &Config{ LabelValueLengthLimit: globLabelValueLengthLimit, ScrapeProtocols: DefaultGlobalConfig.ScrapeProtocols, ScrapeFailureLogFile: globScrapeFailureLogFile, - MetricNameValidationScheme: UTF8ValidationConfig, - MetricNameEscapingScheme: model.AllowUTF8, + MetricNameValidationScheme: DefaultGlobalConfig.MetricNameValidationScheme, + MetricNameEscapingScheme: DefaultGlobalConfig.MetricNameEscapingScheme, AlwaysScrapeClassicHistograms: boolPtr(false), ConvertClassicHistogramsToNHCB: boolPtr(false), diff --git a/scrape/scrape.go b/scrape/scrape.go index cd6f7719be..4d23efdbc8 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -154,7 +154,7 @@ func newScrapePool(cfg *config.ScrapeConfig, app storage.Appendable, offsetSeed return nil, fmt.Errorf("invalid metric name validation scheme: %w", err) } var escapingScheme model.EscapingScheme - escapingScheme, err = model.ToEscapingScheme(cfg.MetricNameEscapingScheme) + escapingScheme, err = config.ToEscapingScheme(cfg.MetricNameEscapingScheme, validationScheme) if err != nil { return nil, fmt.Errorf("invalid metric name escaping scheme, %w", err) }