package main import ( "flag" "fmt" "net/http" "net/url" "strings" "github.com/lovoo/nsq_exporter/collector" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" ) // Version of nsq_exporter. Set at build time. const Version = "0.0.0.dev" var ( listenAddress = flag.String("web.listen", ":9117", "Address on which to expose metrics and web interface.") metricsPath = flag.String("web.path", "/metrics", "Path under which to expose metrics.") nsqUrl = flag.String("nsq.addr", "http://localhost:4151/stats", "Address of the NSQ host.") enabledCollectors = flag.String("collectors", "nsqstats", "Comma-separated list of collectors to use.") namespace = flag.String("namespace", "nsq", "Namespace for the NSQ metrics.") collectorRegistry = map[string]func(name string, x *collector.NsqExecutor) error{ "nsqstats": addStatsCollector, } ) func main() { flag.Parse() ex, err := createNsqExecutor() if err != nil { log.Fatalf("error creating nsq executor: %v", err) } prometheus.MustRegister(ex) handler := prometheus.Handler() if *metricsPath == "" || *metricsPath == "/" { http.Handle(*metricsPath, handler) } else { http.Handle(*metricsPath, handler) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(`