package main import ( "flag" "fmt" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/seiferli/nsq_exporter/collector" "log" "net/http" "net/url" "strings" ) // 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.") nsqdURL = flag.String("nsqd.addr", "http://localhost:4151/stats", "Address of the nsqd node.") enabledCollectors = flag.String("collect", "stats.topics,stats.channels", "Comma-separated list of collectors to use.") namespace = flag.String("namespace", "nsq", "Namespace for the NSQ metrics.") tlsCACert = flag.String("tls.ca_cert", "", "CA certificate file to be used for nsqd connections.") tlsCert = flag.String("tls.cert", "", "TLS certificate file to be used for client connections to nsqd.") tlsKey = flag.String("tls.key", "", "TLS key file to be used for TLS client connections to nsqd.") statsRegistry = map[string]func(namespace string) collector.StatsCollector{ "topics": collector.TopicStats, "channels": collector.ChannelStats, "clients": collector.ClientStats, } ) func main() { flag.Parse() ex, err := createNsqExecutor() if err != nil { log.Fatalf("error creating nsq executor: %v", err) } prometheus.MustRegister(ex) http.Handle(*metricsPath, promhttp.Handler()) if *metricsPath != "" && *metricsPath != "/" { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(`