mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-28 06:59:40 -08:00
Make sure to apply escaping config
This commit is contained in:
parent
df35376983
commit
34308681e8
|
@ -432,6 +432,8 @@ func main() {
|
|||
a.Flag("scrape.discovery-reload-interval", "Interval used by scrape manager to throttle target groups updates.").
|
||||
Hidden().Default("5s").SetValue(&cfg.scrape.DiscoveryReloadInterval)
|
||||
|
||||
a.Flag("scrape.name-escaping-scheme", "method to escape legacy invalid names when sending to an old version of prometheus. can be one of values (default), underscores, or dots").Default(model.DefaultNameEscapingScheme.String()).StringVar(&cfg.scrape.NameEscapingScheme)
|
||||
|
||||
a.Flag("enable-feature", "Comma separated feature names to enable. Valid options: agent, exemplar-storage, expand-external-labels, memory-snapshot-on-shutdown, promql-at-modifier, promql-negative-offset, promql-per-step-stats, promql-experimental-functions, remote-write-receiver (DEPRECATED), extra-scrape-metrics, new-service-discovery-manager, auto-gomaxprocs, no-default-scrape-port, native-histograms, otlp-write-receiver, utf8-names. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details.").
|
||||
Default("").StringsVar(&cfg.featureList)
|
||||
|
||||
|
|
|
@ -81,6 +81,8 @@ type Options struct {
|
|||
// Option to enable the ingestion of the created timestamp as a synthetic zero sample.
|
||||
// See: https://github.com/prometheus/proposals/blob/main/proposals/2023-06-13_created-timestamp.md
|
||||
EnableCreatedTimestampZeroIngestion bool
|
||||
// if UTF8 is not allowed, use this method
|
||||
NameEscapingScheme string
|
||||
|
||||
// Optional HTTP client options to use when scraping.
|
||||
HTTPClientOptions []config_util.HTTPClientOption
|
||||
|
@ -156,6 +158,15 @@ func (m *Manager) reloader() {
|
|||
|
||||
func (m *Manager) reload() {
|
||||
m.mtxScrape.Lock()
|
||||
defer m.mtxScrape.Unlock()
|
||||
var err error
|
||||
model.DefaultNameEscapingScheme, err = model.ToEscapingScheme(m.opts.NameEscapingScheme)
|
||||
level.Info(m.logger).Log("msg", "ESCAPING SCHEME UPDATED", "scheme", m.opts.NameEscapingScheme)
|
||||
if err != nil {
|
||||
level.Error(m.logger).Log("msg", "error setting escaping scheme", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for setName, groups := range m.targetSets {
|
||||
if _, ok := m.scrapePools[setName]; !ok {
|
||||
|
@ -182,7 +193,6 @@ func (m *Manager) reload() {
|
|||
}(m.scrapePools[setName], groups)
|
||||
|
||||
}
|
||||
m.mtxScrape.Unlock()
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
|
|
|
@ -684,7 +684,7 @@ func acceptHeader(sps []config.ScrapeProtocol, allowUTF8Names bool) string {
|
|||
weight := len(config.ScrapeProtocolsHeaders) + 1
|
||||
for _, sp := range sps {
|
||||
val := config.ScrapeProtocolsHeaders[sp]
|
||||
if (sp != config.PrometheusProto || sp == config.OpenMetricsText2_0_0 || sp == config.PrometheusText1_0_0) && allowUTF8Names {
|
||||
if (sp == config.PrometheusProto || sp == config.OpenMetricsText2_0_0 || sp == config.PrometheusText1_0_0) && allowUTF8Names {
|
||||
val += ";" + config.UTF8NamesHeader
|
||||
}
|
||||
val += fmt.Sprintf(";q=0.%d", weight)
|
||||
|
|
Loading…
Reference in a new issue