Skip to content

Commit

Permalink
Initial Prometheus metrics support
Browse files Browse the repository at this point in the history
  • Loading branch information
bakins authored and Brian Akins committed Jul 30, 2018
1 parent 6ed50f1 commit 1ea7337
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
53 changes: 51 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@
[[constraint]]
name = "k8s.io/client-go"
version = "~7.0.0"

[[constraint]]
name = "github.com/prometheus/client_golang"
version = "0.8.0"

[[override]]
name = "github.com/golang/protobuf"
version = "1.1.0"
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"syscall"
"time"

"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"

Expand Down Expand Up @@ -161,10 +162,21 @@ func main() {
)

if metricsAddress != "" {
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/healthz",
func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "OK")
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head><title>chaoskube</title></head>
<body>
<h1>chaoskube</h1>
<p><a href="/metrics">Metrics</a></p>
<p><a href="/healthz">Health Check</a></p>
</body>
</html>`))
})
go func() {
if err := http.ListenAndServe(metricsAddress, nil); err != nil {
log.WithFields(log.Fields{
Expand Down

0 comments on commit 1ea7337

Please sign in to comment.