Skip to content

Commit

Permalink
Merge pull request sysulq#85 from pritpal-sabharwal/add-go-metrics-op…
Browse files Browse the repository at this point in the history
…tion

Add -go.metrics
  • Loading branch information
sysulq authored Mar 24, 2020
2 parents 60540c6 + 46c3e39 commit 6440f4e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nginx_vts_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ var (
nginxScrapeURI = flag.String("nginx.scrape_uri", "http://localhost/status", "URI to nginx stub status page")
insecure = flag.Bool("insecure", true, "Ignore server certificate if using https")
nginxScrapeTimeout = flag.Int("nginx.scrape_timeout", 2, "The number of seconds to wait for an HTTP response from the nginx.scrape_uri")
goMetrics = flag.Bool("go.metrics", false, "Export process and go metrics.")
)

func init() {
Expand All @@ -374,8 +375,11 @@ func main() {

exporter := NewExporter(*nginxScrapeURI)
prometheus.MustRegister(exporter)
prometheus.Unregister(prometheus.NewProcessCollector(os.Getpid(), ""))
prometheus.Unregister(prometheus.NewGoCollector())

if !(*goMetrics) {
prometheus.Unregister(prometheus.NewProcessCollector(os.Getpid(), ""))
prometheus.Unregister(prometheus.NewGoCollector())
}

http.Handle(*metricsEndpoint, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 6440f4e

Please sign in to comment.