mirror of
https://github.com/openfaas/faas.git
synced 2025-06-23 15:23:29 +00:00
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:
27
watchdog/metrics/http.go
Normal file
27
watchdog/metrics/http.go
Normal file
@ -0,0 +1,27 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
type Http struct {
|
||||
RequestsTotal *prometheus.CounterVec
|
||||
RequestDurationHistogram *prometheus.HistogramVec
|
||||
}
|
||||
|
||||
func NewHttp() Http {
|
||||
return Http{
|
||||
RequestsTotal: promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Subsystem: "http",
|
||||
Name: "requests_total",
|
||||
Help: "total HTTP requests processed",
|
||||
}, []string{"code", "method"}),
|
||||
RequestDurationHistogram: promauto.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Subsystem: "http",
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Seconds spent serving HTTP requests.",
|
||||
Buckets: prometheus.DefBuckets,
|
||||
}, []string{"code", "method"}),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user