Skip to content
Snippets Groups Projects
Commit 7cc5e3185411 authored by Alexander Trost's avatar Alexander Trost
Browse files

Added prometheus metrics support

parent a6aca39a6794
No related branches found
No related tags found
No related merge requests found
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)))
}
......@@ -6,7 +6,8 @@
spec:
type: ClusterIP
ports:
- port: 8000
- name: http-metrics
port: 8000
protocol: TCP
selector:
app: __CI_ENVIRONMENT_SLUG__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment