|
|
@ -141,6 +141,7 @@ var ( |
|
|
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
func init() { |
|
|
|
// This can be removed when the default validation scheme in common is updated.
|
|
|
|
// This can be removed when the default validation scheme in common is updated.
|
|
|
|
|
|
|
|
//nolint:staticcheck
|
|
|
|
model.NameValidationScheme = model.UTF8Validation |
|
|
|
model.NameValidationScheme = model.UTF8Validation |
|
|
|
prometheus.MustRegister(versioncollector.NewCollector(strings.ReplaceAll(appName, "-", "_"))) |
|
|
|
prometheus.MustRegister(versioncollector.NewCollector(strings.ReplaceAll(appName, "-", "_"))) |
|
|
|
|
|
|
|
|
|
|
@ -617,6 +618,31 @@ func main() { |
|
|
|
cfg.tsdb.OutOfOrderTimeWindow = cfgFile.StorageConfig.TSDBConfig.OutOfOrderTimeWindow |
|
|
|
cfg.tsdb.OutOfOrderTimeWindow = cfgFile.StorageConfig.TSDBConfig.OutOfOrderTimeWindow |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set Go runtime parameters before we get too far into initialization.
|
|
|
|
|
|
|
|
updateGoGC(cfgFile, logger) |
|
|
|
|
|
|
|
if cfg.maxprocsEnable { |
|
|
|
|
|
|
|
l := func(format string, a ...interface{}) { |
|
|
|
|
|
|
|
logger.Info(fmt.Sprintf(strings.TrimPrefix(format, "maxprocs: "), a...), "component", "automaxprocs") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if _, err := maxprocs.Set(maxprocs.Logger(l)); err != nil { |
|
|
|
|
|
|
|
logger.Warn("Failed to set GOMAXPROCS automatically", "component", "automaxprocs", "err", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if cfg.memlimitEnable { |
|
|
|
|
|
|
|
if _, err := memlimit.SetGoMemLimitWithOpts( |
|
|
|
|
|
|
|
memlimit.WithRatio(cfg.memlimitRatio), |
|
|
|
|
|
|
|
memlimit.WithProvider( |
|
|
|
|
|
|
|
memlimit.ApplyFallback( |
|
|
|
|
|
|
|
memlimit.FromCgroup, |
|
|
|
|
|
|
|
memlimit.FromSystem, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); err != nil { |
|
|
|
|
|
|
|
logger.Warn("automemlimit", "msg", "Failed to set GOMEMLIMIT automatically", "err", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Now that the validity of the config is established, set the config
|
|
|
|
// Now that the validity of the config is established, set the config
|
|
|
|
// success metrics accordingly, although the config isn't really loaded
|
|
|
|
// success metrics accordingly, although the config isn't really loaded
|
|
|
|
// yet. This will happen later (including setting these metrics again),
|
|
|
|
// yet. This will happen later (including setting these metrics again),
|
|
|
@ -763,29 +789,6 @@ func main() { |
|
|
|
ruleManager *rules.Manager |
|
|
|
ruleManager *rules.Manager |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if cfg.maxprocsEnable { |
|
|
|
|
|
|
|
l := func(format string, a ...interface{}) { |
|
|
|
|
|
|
|
logger.Info(fmt.Sprintf(strings.TrimPrefix(format, "maxprocs: "), a...), "component", "automaxprocs") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if _, err := maxprocs.Set(maxprocs.Logger(l)); err != nil { |
|
|
|
|
|
|
|
logger.Warn("Failed to set GOMAXPROCS automatically", "component", "automaxprocs", "err", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if cfg.memlimitEnable { |
|
|
|
|
|
|
|
if _, err := memlimit.SetGoMemLimitWithOpts( |
|
|
|
|
|
|
|
memlimit.WithRatio(cfg.memlimitRatio), |
|
|
|
|
|
|
|
memlimit.WithProvider( |
|
|
|
|
|
|
|
memlimit.ApplyFallback( |
|
|
|
|
|
|
|
memlimit.FromCgroup, |
|
|
|
|
|
|
|
memlimit.FromSystem, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); err != nil { |
|
|
|
|
|
|
|
logger.Warn("automemlimit", "msg", "Failed to set GOMEMLIMIT automatically", "err", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !agentMode { |
|
|
|
if !agentMode { |
|
|
|
opts := promql.EngineOpts{ |
|
|
|
opts := promql.EngineOpts{ |
|
|
|
Logger: logger.With("component", "query engine"), |
|
|
|
Logger: logger.With("component", "query engine"), |
|
|
@ -1471,6 +1474,14 @@ func reloadConfig(filename string, enableExemplarStorage bool, logger *slog.Logg |
|
|
|
return fmt.Errorf("one or more errors occurred while applying the new configuration (--config.file=%q)", filename) |
|
|
|
return fmt.Errorf("one or more errors occurred while applying the new configuration (--config.file=%q)", filename) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateGoGC(conf, logger) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
noStepSuqueryInterval.Set(conf.GlobalConfig.EvaluationInterval) |
|
|
|
|
|
|
|
timingsLogger.Info("Completed loading of configuration file", "filename", filename, "totalDuration", time.Since(start)) |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func updateGoGC(conf *config.Config, logger *slog.Logger) { |
|
|
|
oldGoGC := debug.SetGCPercent(conf.Runtime.GoGC) |
|
|
|
oldGoGC := debug.SetGCPercent(conf.Runtime.GoGC) |
|
|
|
if oldGoGC != conf.Runtime.GoGC { |
|
|
|
if oldGoGC != conf.Runtime.GoGC { |
|
|
|
logger.Info("updated GOGC", "old", oldGoGC, "new", conf.Runtime.GoGC) |
|
|
|
logger.Info("updated GOGC", "old", oldGoGC, "new", conf.Runtime.GoGC) |
|
|
@ -1481,10 +1492,6 @@ func reloadConfig(filename string, enableExemplarStorage bool, logger *slog.Logg |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
os.Setenv("GOGC", "off") |
|
|
|
os.Setenv("GOGC", "off") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
noStepSuqueryInterval.Set(conf.GlobalConfig.EvaluationInterval) |
|
|
|
|
|
|
|
timingsLogger.Info("Completed loading of configuration file", "filename", filename, "totalDuration", time.Since(start)) |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func startsOrEndsWithQuote(s string) bool { |
|
|
|
func startsOrEndsWithQuote(s string) bool { |
|
|
|