Skip to content

Commit

Permalink
Merge pull request #97 from bakins/initial-proemtheus
Browse files Browse the repository at this point in the history
Initial Proemtheus metrics support
  • Loading branch information
linki authored Aug 3, 2018
2 parents 6ed50f1 + 1ea7337 commit 3861bf2
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 3861bf2

Please sign in to comment.