mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Make HTTP listen address a flag.
This commit is contained in:
parent
0cbd03ccf9
commit
2859227fdb
|
@ -15,6 +15,7 @@ package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.google.com/p/gorest"
|
"code.google.com/p/gorest"
|
||||||
|
"flag"
|
||||||
"github.com/prometheus/client_golang"
|
"github.com/prometheus/client_golang"
|
||||||
"github.com/prometheus/prometheus/storage/metric"
|
"github.com/prometheus/prometheus/storage/metric"
|
||||||
"github.com/prometheus/prometheus/web/api"
|
"github.com/prometheus/prometheus/web/api"
|
||||||
|
@ -22,6 +23,11 @@ import (
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Commandline flags.
|
||||||
|
var (
|
||||||
|
listenAddress = flag.String("listenAddress", ":9090", "Address to listen on for web interface.")
|
||||||
|
)
|
||||||
|
|
||||||
func StartServing(persistence metric.MetricPersistence) {
|
func StartServing(persistence metric.MetricPersistence) {
|
||||||
gorest.RegisterService(api.NewMetricsService(persistence))
|
gorest.RegisterService(api.NewMetricsService(persistence))
|
||||||
exporter := registry.DefaultRegistry.YieldExporter()
|
exporter := registry.DefaultRegistry.YieldExporter()
|
||||||
|
@ -30,5 +36,5 @@ func StartServing(persistence metric.MetricPersistence) {
|
||||||
http.Handle("/metrics.json", exporter)
|
http.Handle("/metrics.json", exporter)
|
||||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("web/static"))))
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("web/static"))))
|
||||||
|
|
||||||
go http.ListenAndServe(":9090", nil)
|
go http.ListenAndServe(*listenAddress, nil)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue