Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cli.Command{ Name: "serve", Usage: "Launch a http server that serves queries in prometheus format", Flags: []cli.Flag{ &cli.StringFlag{ Name: "listen-addr", Usage: "server listen `HOST:ADDR`", Value: ":16480", }, }, Action: func(c *cli.Context) error { mux := http.NewServeMux() fetcher := fetch.NewCachedFetcher(fetch.Direct{}) mux.Handle("/probe", exporter.Handler{Fetcher: fetcher}) prometheus.MustRegister(prometheus.NewBuildInfoCollector()) mux.Handle("/metrics", promhttp.Handler()) mux.HandleFunc("/healthz", func(w http.ResponseWriter, req *http.Request) { w.Header().Set("content-type", "text/plain") if _, err := w.Write([]byte("ok\n")); err != nil { zap.S().Warnf("Failed to write ok: %v", err) } }) mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { w.Header().Set("content-type", "text/html; charset=UTF-8") if _, err := w.Write(indexhtml); err != nil { zap.S().Warnf("Failed to write index.html: %v", err) } }) listenAddr := c.String("listen-addr") zap.S().Infof("About to start listening on %s", listenAddr) if err := http.ListenAndServe(listenAddr, mux); err != nil { return err } return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.