forked from mirrors/statsd_exporter
Merge pull request #6 from prometheus/flag-cleanup
Make flag names consistent across projects.
This commit is contained in:
commit
5488430fad
1 changed files with 11 additions and 10 deletions
21
main.go
21
main.go
|
@ -18,20 +18,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
listeningAddress = flag.String("listeningAddress", ":8080", "The address on which to expose generated Prometheus metrics.")
|
listenAddress = flag.String("web.listen-address", ":9102", "The address on which to expose the web interface and generated Prometheus metrics.")
|
||||||
statsdListeningAddress = flag.String("statsdListeningAddress", ":9125", "The UDP address on which to receive statsd metric lines.")
|
metricsEndpoint = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
|
||||||
mappingConfig = flag.String("mappingConfig", "", "Metric mapping configuration file name.")
|
statsdListenAddress = flag.String("statsd.listen-address", ":9125", "The UDP address on which to receive statsd metric lines.")
|
||||||
|
mappingConfig = flag.String("statsd.mapping-config", "", "Metric mapping configuration file name.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func serveHTTP() {
|
func serveHTTP() {
|
||||||
http.Handle("/metrics", prometheus.Handler())
|
http.Handle(*metricsEndpoint, prometheus.Handler())
|
||||||
http.ListenAndServe(*listeningAddress, nil)
|
http.ListenAndServe(*listenAddress, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func udpAddrFromString(addr string) *net.UDPAddr {
|
func udpAddrFromString(addr string) *net.UDPAddr {
|
||||||
host, portStr, err := net.SplitHostPort(*statsdListeningAddress)
|
host, portStr, err := net.SplitHostPort(*statsdListenAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Bad StatsD listening address", *statsdListeningAddress)
|
log.Fatal("Bad StatsD listening address", *statsdListenAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
if host == "" {
|
if host == "" {
|
||||||
|
@ -91,15 +92,15 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
log.Println("Starting StatsD -> Prometheus Bridge...")
|
log.Println("Starting StatsD -> Prometheus Bridge...")
|
||||||
log.Println("Accepting StatsD Traffic on", *statsdListeningAddress)
|
log.Println("Accepting StatsD Traffic on", *statsdListenAddress)
|
||||||
log.Println("Accepting Prometheus Requests on", *listeningAddress)
|
log.Println("Accepting Prometheus Requests on", *listenAddress)
|
||||||
|
|
||||||
go serveHTTP()
|
go serveHTTP()
|
||||||
|
|
||||||
events := make(chan Events, 1024)
|
events := make(chan Events, 1024)
|
||||||
defer close(events)
|
defer close(events)
|
||||||
|
|
||||||
listenAddr := udpAddrFromString(*statsdListeningAddress)
|
listenAddr := udpAddrFromString(*statsdListenAddress)
|
||||||
conn, err := net.ListenUDP("udp", listenAddr)
|
conn, err := net.ListenUDP("udp", listenAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in a new issue