-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (30 loc) · 991 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"flag"
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
listenAddress = flag.String("web.listen-address", ":9888", "Address to listen on for web interface.")
metricPath = flag.String("web.metrics-path", "/metrics", "Path under which to expose metrics.")
)
func main() {
log.Fatal(serverMetrics(*listenAddress, *metricPath))
}
func serverMetrics(listenAddress, metricsPath string) error {
http.Handle(metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`
<html>
<head><title>Volume Exporter Metrics</title></head>
<body>
<h1>ConfigMap Reload</h1>
<p><a href='` + metricsPath + `'>Metrics</a></p>
</body>
</html>
`))
})
return http.ListenAndServe(listenAddress, nil)
}