mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-22 23:41:00 +00:00
Support checking configuration and exiting
If desired, go through all the motions of setting up the exporter, but then exit. This is not very elegant, as we actually open the ports, which may not be what you want to do in a pipeline, but it is the quickest way to implement this. Fixes #263. Signed-off-by: Matthias Rampke <matthias@prometheus.io>
This commit is contained in:
parent
3b3ff3c473
commit
c8b8ddc952
2 changed files with 40 additions and 21 deletions
48
README.md
48
README.md
|
@ -81,42 +81,56 @@ NOTE: Version 0.7.0 switched to the [kingpin](https://github.com/alecthomas/king
|
||||||
* flag processing stops at the first `--`
|
* flag processing stops at the first `--`
|
||||||
|
|
||||||
```
|
```
|
||||||
$ go build
|
|
||||||
$ ./statsd_exporter --help
|
|
||||||
usage: statsd_exporter [<flags>]
|
usage: statsd_exporter [<flags>]
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help Show context-sensitive help (also try --help-long and --help-man).
|
-h, --help Show context-sensitive help (also try
|
||||||
|
--help-long and --help-man).
|
||||||
--web.listen-address=":9102"
|
--web.listen-address=":9102"
|
||||||
The address on which to expose the web interface and generated Prometheus metrics.
|
The address on which to expose the web interface
|
||||||
|
and generated Prometheus metrics.
|
||||||
--web.telemetry-path="/metrics"
|
--web.telemetry-path="/metrics"
|
||||||
Path under which to expose metrics.
|
Path under which to expose metrics.
|
||||||
--statsd.listen-udp=":9125"
|
--statsd.listen-udp=":9125"
|
||||||
The UDP address on which to receive statsd metric lines. "" disables it.
|
The UDP address on which to receive statsd
|
||||||
|
metric lines. "" disables it.
|
||||||
--statsd.listen-tcp=":9125"
|
--statsd.listen-tcp=":9125"
|
||||||
The TCP address on which to receive statsd metric lines. "" disables it.
|
The TCP address on which to receive statsd
|
||||||
|
metric lines. "" disables it.
|
||||||
--statsd.listen-unixgram=""
|
--statsd.listen-unixgram=""
|
||||||
The Unixgram socket path to receive statsd metric lines in datagram. "" disables it.
|
The Unixgram socket path to receive statsd
|
||||||
|
metric lines in datagram. "" disables it.
|
||||||
--statsd.unixsocket-mode="755"
|
--statsd.unixsocket-mode="755"
|
||||||
The permission mode of the unix socket.
|
The permission mode of the unix socket.
|
||||||
--statsd.mapping-config=STATSD.MAPPING-CONFIG
|
--statsd.mapping-config=STATSD.MAPPING-CONFIG
|
||||||
Metric mapping configuration file name.
|
Metric mapping configuration file name.
|
||||||
--statsd.read-buffer=STATSD.READ-BUFFER
|
--statsd.read-buffer=STATSD.READ-BUFFER
|
||||||
Size (in bytes) of the operating system's transmit read buffer associated with the UDP or Unixgram connection. Please make sure the kernel parameters net.core.rmem_max is set to
|
Size (in bytes) of the operating system's
|
||||||
a value greater than the value specified.
|
transmit read buffer associated with the UDP or
|
||||||
--statsd.cache-size=1000 Maximum size of your metric mapping cache. Relies on least recently used replacement policy if max size is reached.
|
Unixgram connection. Please make sure the kernel
|
||||||
|
parameters net.core.rmem_max is set to a value
|
||||||
|
greater than the value specified.
|
||||||
|
--statsd.cache-size=1000 Maximum size of your metric mapping cache.
|
||||||
|
Relies on least recently used replacement policy
|
||||||
|
if max size is reached.
|
||||||
|
--statsd.cache-type=lru Metric mapping cache type. Valid options are
|
||||||
|
"lru" and "random"
|
||||||
--statsd.event-queue-size=10000
|
--statsd.event-queue-size=10000
|
||||||
Size of internal queue for processing events
|
Size of internal queue for processing events
|
||||||
--statsd.event-flush-threshold=1000
|
--statsd.event-flush-threshold=1000
|
||||||
Number of events to hold in queue before flushing
|
Number of events to hold in queue before
|
||||||
|
flushing
|
||||||
--statsd.event-flush-interval=200ms
|
--statsd.event-flush-interval=200ms
|
||||||
Number of events to hold in queue before flushing
|
Number of events to hold in queue before
|
||||||
--debug.dump-fsm="" The path to dump internal FSM generated for glob matching as Dot file.
|
flushing
|
||||||
--log.level="info" Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]
|
--debug.dump-fsm="" The path to dump internal FSM generated for glob
|
||||||
--log.format="logger:stderr"
|
matching as Dot file.
|
||||||
Set the log target and format. Example: "logger:syslog?appname=bob& local=7" or "logger:stdout?json=true"
|
--check-config Check configuration and exit.
|
||||||
|
--log.level=info Only log messages with the given severity or
|
||||||
|
above. One of: [debug, info, warn, error]
|
||||||
|
--log.format=logfmt Output format of log messages. One of: [logfmt,
|
||||||
|
json]
|
||||||
--version Show application version.
|
--version Show application version.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
9
main.go
9
main.go
|
@ -267,6 +267,7 @@ func main() {
|
||||||
eventFlushThreshold = kingpin.Flag("statsd.event-flush-threshold", "Number of events to hold in queue before flushing").Default("1000").Int()
|
eventFlushThreshold = kingpin.Flag("statsd.event-flush-threshold", "Number of events to hold in queue before flushing").Default("1000").Int()
|
||||||
eventFlushInterval = kingpin.Flag("statsd.event-flush-interval", "Number of events to hold in queue before flushing").Default("200ms").Duration()
|
eventFlushInterval = kingpin.Flag("statsd.event-flush-interval", "Number of events to hold in queue before flushing").Default("200ms").Duration()
|
||||||
dumpFSMPath = kingpin.Flag("debug.dump-fsm", "The path to dump internal FSM generated for glob matching as Dot file.").Default("").String()
|
dumpFSMPath = kingpin.Flag("debug.dump-fsm", "The path to dump internal FSM generated for glob matching as Dot file.").Default("").String()
|
||||||
|
checkConfig = kingpin.Flag("check-config", "Check configuration and exit.").Default("false").Bool()
|
||||||
)
|
)
|
||||||
|
|
||||||
promlogConfig := &promlog.Config{}
|
promlogConfig := &promlog.Config{}
|
||||||
|
@ -440,13 +441,17 @@ func main() {
|
||||||
mapper.InitCache(*cacheSize, cacheOption)
|
mapper.InitCache(*cacheSize, cacheOption)
|
||||||
}
|
}
|
||||||
|
|
||||||
go configReloader(*mappingConfig, mapper, *cacheSize, logger, cacheOption)
|
|
||||||
|
|
||||||
exporter := exporter.NewExporter(mapper, logger, eventsActions, eventsUnmapped, errorEventStats, eventStats, conflictingEventStats, metricsCount)
|
exporter := exporter.NewExporter(mapper, logger, eventsActions, eventsUnmapped, errorEventStats, eventStats, conflictingEventStats, metricsCount)
|
||||||
|
|
||||||
|
if *checkConfig {
|
||||||
|
level.Info(logger).Log("msg", "Configuration check successful, exiting")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
signals := make(chan os.Signal, 1)
|
signals := make(chan os.Signal, 1)
|
||||||
signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
|
go configReloader(*mappingConfig, mapper, *cacheSize, logger, cacheOption)
|
||||||
go exporter.Listen(events)
|
go exporter.Listen(events)
|
||||||
|
|
||||||
<-signals
|
<-signals
|
||||||
|
|
Loading…
Reference in a new issue