Skip to content

Commit

Permalink
Initial Prometheus metrics support
Browse files Browse the repository at this point in the history
  • Loading branch information
bakins committed Jul 29, 2018
1 parent 3889705 commit 657063b
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 @@ -7,6 +7,7 @@ import (
"os"
"time"

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

Expand Down Expand Up @@ -154,10 +155,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 657063b

Please sign in to comment.