diff --git a/main.go b/main.go index a6aca39a67941825529b7ecacb61ad6a52614dbe_bWFpbi5nbw==..7cc5e3185411ed88fc39edaaff967d93dde0cf76_bWFpbi5nbw== 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,10 @@ package main import ( + "flag" "net/http" "os" "time" log "github.com/Sirupsen/logrus" "github.com/gorilla/handlers" @@ -4,10 +5,11 @@ "net/http" "os" "time" log "github.com/Sirupsen/logrus" "github.com/gorilla/handlers" + "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/version" ) var ready = false @@ -10,6 +12,7 @@ "github.com/prometheus/common/version" ) var ready = false +var addr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.") func main() { @@ -14,5 +17,6 @@ func main() { + flag.Parse() log.Info("Starting presentation-gitlab-k8s application..") http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { hostname, _ := os.Hostname() @@ -30,8 +34,9 @@ w.Write([]byte("500")) } }) + http.Handle("/metrics", promhttp.Handler()) go func() { <-time.After(5 * time.Second) ready = true log.Info("Application is ready!") }() @@ -33,8 +38,8 @@ go func() { <-time.After(5 * time.Second) ready = true log.Info("Application is ready!") }() - log.Info("Listen on :8000") - log.Fatal(http.ListenAndServe(":8000", handlers.LoggingHandler(os.Stdout, http.DefaultServeMux))) + log.Info("Listen on " + *addr) + log.Fatal(http.ListenAndServe(*addr, handlers.LoggingHandler(os.Stdout, http.DefaultServeMux))) } diff --git a/service.yaml b/service.yaml index a6aca39a67941825529b7ecacb61ad6a52614dbe_c2VydmljZS55YW1s..7cc5e3185411ed88fc39edaaff967d93dde0cf76_c2VydmljZS55YW1s 100644 --- a/service.yaml +++ b/service.yaml @@ -6,7 +6,8 @@ spec: type: ClusterIP ports: - - port: 8000 + - name: http-metrics + port: 8000 protocol: TCP selector: app: __CI_ENVIRONMENT_SLUG__