}
type resultHistory struct {
- mu sync.Mutex
- nextId int64
- results []*result
+ mu sync.Mutex
+ nextId int64
+ results []*result
+ maxResults uint
}
// Add a result to the history.
rh.nextId++
rh.results = append(rh.results, r)
- if len(rh.results) > 100 {
+ if uint(len(rh.results)) > rh.maxResults {
results := make([]*result, len(rh.results)-1)
copy(results, rh.results[1:])
rh.results = results
listenAddress = kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests.").Default(":9115").String()
timeoutOffset = kingpin.Flag("timeout-offset", "Offset to subtract from timeout in seconds.").Default("0.5").Float64()
configCheck = kingpin.Flag("config.check", "If true validate the config file and then exit.").Default().Bool()
+ historyLimit = kingpin.Flag("history.limit", "The maximum amount of items to keep in the history.").Default("100").Uint()
Probers = map[string]prober.ProbeFn{
"http": prober.ProbeHTTP,
kingpin.HelpFlag.Short('h')
kingpin.Parse()
logger := promlog.New(allowedLevel)
- rh := &resultHistory{}
+ rh := &resultHistory{maxResults: *historyLimit}
level.Info(logger).Log("msg", "Starting blackbox_exporter", "version", version.Info())
level.Info(logger).Log("msg", "Build context", version.BuildContext())