Add RED metrics

- this PR adds metrics via Prometheus for instrumentation and
to move towards using HPAv2 / custom metrics in Kubernetes.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2019-04-03 22:03:44 +01:00
parent 1b61954ad9
commit 634ec22c8d
125 changed files with 33018 additions and 9 deletions

View File

@ -19,6 +19,7 @@ import (
"syscall"
"time"
"github.com/openfaas/faas/watchdog/metrics"
"github.com/openfaas/faas/watchdog/types"
)
@ -58,12 +59,19 @@ func main() {
MaxHeaderBytes: 1 << 20, // Max header of 1MB
}
httpMetrics := metrics.NewHttp()
log.Printf("Read/write timeout: %s, %s. Port: %d\n", readTimeout, writeTimeout, config.port)
http.HandleFunc("/_/health", makeHealthHandler())
http.HandleFunc("/", makeRequestHandler(&config))
http.HandleFunc("/", metrics.InstrumentHandler(makeRequestHandler(&config), httpMetrics))
metricsServer := metrics.MetricsServer{}
metricsServer.Register(config.metricsPort)
cancel := make(chan bool)
go metricsServer.Serve(cancel)
shutdownTimeout := config.writeTimeout
listenUntilShutdown(shutdownTimeout, s, config.suppressLock)
}