mirror of
https://github.com/openfaas/faas.git
synced 2025-06-25 08:13:25 +00:00
Introduce gateway_function_invocation_total to track individual functions
Introduce prometheus_alertmanager into stack - have it fire into webhook stash
This commit is contained in:
@ -10,4 +10,4 @@ docker rm -f gateway_extract
|
||||
|
||||
echo Building alexellis2/faas-gateway:latest
|
||||
|
||||
docker build -t alexellis2/faas-gateway:latest .
|
||||
docker build -t alexellis2/faas-gateway:latest-dev .
|
||||
|
@ -11,6 +11,7 @@ type MetricOptions struct {
|
||||
GatewayRequestsTotal prometheus.Counter
|
||||
GatewayServerlessServedTotal prometheus.Counter
|
||||
GatewayFunctions prometheus.Histogram
|
||||
GatewayFunctionInvocation *prometheus.CounterVec
|
||||
}
|
||||
|
||||
// PrometheusHandler Bootstraps prometheus for metrics collection
|
||||
|
@ -72,6 +72,8 @@ func isAlexa(requestBody []byte) AlexaRequestBody {
|
||||
}
|
||||
|
||||
func invokeService(w http.ResponseWriter, r *http.Request, metrics metrics.MetricOptions, service string, requestBody []byte) {
|
||||
metrics.GatewayFunctionInvocation.WithLabelValues(service).Add(1)
|
||||
|
||||
stamp := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
|
||||
start := time.Now()
|
||||
@ -171,15 +173,24 @@ func main() {
|
||||
Name: "gateway_functions",
|
||||
Help: "Gateway functions",
|
||||
})
|
||||
GatewayFunctionInvocation := prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "gateway_function_invocation_total",
|
||||
Help: "Individual function metrics",
|
||||
},
|
||||
[]string{"function_name"},
|
||||
)
|
||||
|
||||
prometheus.Register(GatewayRequestsTotal)
|
||||
prometheus.Register(GatewayServerlessServedTotal)
|
||||
prometheus.Register(GatewayFunctions)
|
||||
prometheus.Register(GatewayFunctionInvocation)
|
||||
|
||||
metricsOptions := metrics.MetricOptions{
|
||||
GatewayRequestsTotal: GatewayRequestsTotal,
|
||||
GatewayServerlessServedTotal: GatewayServerlessServedTotal,
|
||||
GatewayFunctions: GatewayFunctions,
|
||||
GatewayFunctionInvocation: GatewayFunctionInvocation,
|
||||
}
|
||||
|
||||
r := mux.NewRouter()
|
||||
|
Reference in New Issue
Block a user