Skip to content

Commit 1ea7337

Browse files
bakinsBrian Akins
authored and
Brian Akins
committed
Initial Prometheus metrics support
1 parent 6ed50f1 commit 1ea7337

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed

Gopkg.lock

+51-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+8
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@
2121
[[constraint]]
2222
name = "k8s.io/client-go"
2323
version = "~7.0.0"
24+
25+
[[constraint]]
26+
name = "github.com/prometheus/client_golang"
27+
version = "0.8.0"
28+
29+
[[override]]
30+
name = "github.com/golang/protobuf"
31+
version = "1.1.0"

main.go

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"syscall"
1111
"time"
1212

13+
"github.com/prometheus/client_golang/prometheus/promhttp"
1314
log "github.com/sirupsen/logrus"
1415
"gopkg.in/alecthomas/kingpin.v2"
1516

@@ -161,10 +162,21 @@ func main() {
161162
)
162163

163164
if metricsAddress != "" {
165+
http.Handle("/metrics", promhttp.Handler())
164166
http.HandleFunc("/healthz",
165167
func(w http.ResponseWriter, r *http.Request) {
166168
fmt.Fprintln(w, "OK")
167169
})
170+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
171+
w.Write([]byte(`<html>
172+
<head><title>chaoskube</title></head>
173+
<body>
174+
<h1>chaoskube</h1>
175+
<p><a href="/metrics">Metrics</a></p>
176+
<p><a href="/healthz">Health Check</a></p>
177+
</body>
178+
</html>`))
179+
})
168180
go func() {
169181
if err := http.ListenAndServe(metricsAddress, nil); err != nil {
170182
log.WithFields(log.Fields{

0 commit comments

Comments
 (0)