Skip to content

Commit

Permalink
Add landing page to exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley Primo committed Oct 23, 2019
1 parent 7ac3254 commit 64c7263
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ha_cluster_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ func NewMetricDesc(subsystem, name, help string, variableLabels []string) *prome
return prometheus.NewDesc(prometheus.BuildFQName(NAMESPACE, subsystem, name), help, variableLabels, nil)
}

// Landing Page (for /)
func landingpage(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head>
<title>HACluster Exporter</title>
</head>
<body>
<h1>HACluster Exporter</h1>
<p><a href="metrics">Metrics</a></p>
<br />
<h2>More information:</h2>
<p><a href="https://github.com/ClusterLabs/ha_cluster_exporter">github.com/ClusterLabs/ha_cluster_exporter</a></p>
</body>
</html>`))
}

var (
clock Clock = &SystemClock{}
portNumber = flag.String("port", "9002", "The port number to listen on for HTTP requests.")
Expand Down Expand Up @@ -94,7 +110,8 @@ func main() {
prometheus.MustRegister(drbdCollector)
}

http.HandleFunc("/", landingpage)
http.Handle("/metrics", promhttp.Handler())
log.Infoln("Serving metrics on port", *portNumber)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", *portNumber), nil))
}
}

0 comments on commit 64c7263

Please sign in to comment.