mirror of
https://github.com/openfaas/faas.git
synced 2025-06-08 16:26:47 +00:00
Remove OpenFaaS Pro metrics from OpenFaaS CE
* Removes service min and target metrics from the CE gateway OpenFaaS Pro metrics are no longer required in OpenFaaS CE since there is an OpenFaaS Pro gateway available. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
This commit is contained in:
parent
dc2a7a0c6e
commit
9fccc67b9c
@ -211,8 +211,6 @@ func main() {
|
|||||||
decorateExternalAuth(faasHandlers.FunctionStatus, config.UpstreamTimeout, config.AuthProxyURL, config.AuthProxyPassBody)
|
decorateExternalAuth(faasHandlers.FunctionStatus, config.UpstreamTimeout, config.AuthProxyURL, config.AuthProxyPassBody)
|
||||||
faasHandlers.InfoHandler =
|
faasHandlers.InfoHandler =
|
||||||
decorateExternalAuth(faasHandlers.InfoHandler, config.UpstreamTimeout, config.AuthProxyURL, config.AuthProxyPassBody)
|
decorateExternalAuth(faasHandlers.InfoHandler, config.UpstreamTimeout, config.AuthProxyURL, config.AuthProxyPassBody)
|
||||||
faasHandlers.AsyncReport =
|
|
||||||
decorateExternalAuth(faasHandlers.AsyncReport, config.UpstreamTimeout, config.AuthProxyURL, config.AuthProxyPassBody)
|
|
||||||
faasHandlers.SecretHandler =
|
faasHandlers.SecretHandler =
|
||||||
decorateExternalAuth(faasHandlers.SecretHandler, config.UpstreamTimeout, config.AuthProxyURL, config.AuthProxyPassBody)
|
decorateExternalAuth(faasHandlers.SecretHandler, config.UpstreamTimeout, config.AuthProxyURL, config.AuthProxyPassBody)
|
||||||
faasHandlers.LogProxyHandler =
|
faasHandlers.LogProxyHandler =
|
||||||
@ -247,8 +245,6 @@ func main() {
|
|||||||
r.HandleFunc("/async-function/{name:["+NameExpression+"]+}/", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
r.HandleFunc("/async-function/{name:["+NameExpression+"]+}/", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/async-function/{name:["+NameExpression+"]+}", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
r.HandleFunc("/async-function/{name:["+NameExpression+"]+}", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/async-function/{name:["+NameExpression+"]+}/{params:.*}", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
r.HandleFunc("/async-function/{name:["+NameExpression+"]+}/{params:.*}", faasHandlers.QueuedProxy).Methods(http.MethodPost)
|
||||||
|
|
||||||
r.HandleFunc("/system/async-report", handlers.MakeNotifierWrapper(faasHandlers.AsyncReport, forwardingNotifiers))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fs := http.FileServer(http.Dir("./assets/"))
|
fs := http.FileServer(http.Dir("./assets/"))
|
||||||
|
@ -12,14 +12,12 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/openfaas/faas-provider/auth"
|
"github.com/openfaas/faas-provider/auth"
|
||||||
types "github.com/openfaas/faas-provider/types"
|
types "github.com/openfaas/faas-provider/types"
|
||||||
"github.com/openfaas/faas/gateway/scaling"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,7 +46,6 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
|
|||||||
e.metricOptions.GatewayFunctionsHistogram.Describe(ch)
|
e.metricOptions.GatewayFunctionsHistogram.Describe(ch)
|
||||||
e.metricOptions.ServiceReplicasGauge.Describe(ch)
|
e.metricOptions.ServiceReplicasGauge.Describe(ch)
|
||||||
e.metricOptions.GatewayFunctionInvocationStarted.Describe(ch)
|
e.metricOptions.GatewayFunctionInvocationStarted.Describe(ch)
|
||||||
e.metricOptions.ServiceTargetLoadGauge.Describe(ch)
|
|
||||||
|
|
||||||
e.metricOptions.ServiceMetrics.Counter.Describe(ch)
|
e.metricOptions.ServiceMetrics.Counter.Describe(ch)
|
||||||
e.metricOptions.ServiceMetrics.Histogram.Describe(ch)
|
e.metricOptions.ServiceMetrics.Histogram.Describe(ch)
|
||||||
@ -62,7 +59,6 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
|||||||
e.metricOptions.GatewayFunctionInvocationStarted.Collect(ch)
|
e.metricOptions.GatewayFunctionInvocationStarted.Collect(ch)
|
||||||
|
|
||||||
e.metricOptions.ServiceReplicasGauge.Reset()
|
e.metricOptions.ServiceReplicasGauge.Reset()
|
||||||
e.metricOptions.ServiceTargetLoadGauge.Reset()
|
|
||||||
|
|
||||||
for _, service := range e.services {
|
for _, service := range e.services {
|
||||||
var serviceName string
|
var serviceName string
|
||||||
@ -76,49 +72,9 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
|||||||
e.metricOptions.ServiceReplicasGauge.
|
e.metricOptions.ServiceReplicasGauge.
|
||||||
WithLabelValues(serviceName).
|
WithLabelValues(serviceName).
|
||||||
Set(float64(service.Replicas))
|
Set(float64(service.Replicas))
|
||||||
|
|
||||||
// Set minimum replicas
|
|
||||||
minReplicas := scaling.DefaultMinReplicas
|
|
||||||
if service.Labels != nil {
|
|
||||||
a := *service.Labels
|
|
||||||
if v, ok := a[scaling.MinScaleLabel]; ok && len(v) > 0 {
|
|
||||||
val, _ := strconv.Atoi(v)
|
|
||||||
minReplicas = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
e.metricOptions.ServiceMinReplicasGauge.
|
|
||||||
WithLabelValues(serviceName).
|
|
||||||
Set(float64(minReplicas))
|
|
||||||
|
|
||||||
// Set scale type
|
|
||||||
scaleType := scaling.DefaultTypeScale
|
|
||||||
if service.Labels != nil {
|
|
||||||
a := *service.Labels
|
|
||||||
if v, ok := a[scaling.ScaleTypeLabel]; ok && len(v) > 0 {
|
|
||||||
scaleType = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target load
|
|
||||||
targetScale := scaling.DefaultTargetLoad
|
|
||||||
if service.Labels != nil {
|
|
||||||
a := *service.Labels
|
|
||||||
if v, ok := a[scaling.TargetLoadLabel]; ok && len(v) > 0 {
|
|
||||||
val, _ := strconv.Atoi(v)
|
|
||||||
targetScale = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
e.metricOptions.ServiceTargetLoadGauge.
|
|
||||||
WithLabelValues(serviceName, scaleType).
|
|
||||||
Set(float64(targetScale))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.metricOptions.ServiceReplicasGauge.Collect(ch)
|
e.metricOptions.ServiceReplicasGauge.Collect(ch)
|
||||||
e.metricOptions.ServiceMinReplicasGauge.Collect(ch)
|
|
||||||
e.metricOptions.ServiceTargetLoadGauge.Collect(ch)
|
|
||||||
|
|
||||||
e.metricOptions.ServiceMetrics.Counter.Collect(ch)
|
e.metricOptions.ServiceMetrics.Counter.Collect(ch)
|
||||||
e.metricOptions.ServiceMetrics.Histogram.Collect(ch)
|
e.metricOptions.ServiceMetrics.Histogram.Collect(ch)
|
||||||
|
@ -17,9 +17,7 @@ type MetricOptions struct {
|
|||||||
GatewayFunctionsHistogram *prometheus.HistogramVec
|
GatewayFunctionsHistogram *prometheus.HistogramVec
|
||||||
GatewayFunctionInvocationStarted *prometheus.CounterVec
|
GatewayFunctionInvocationStarted *prometheus.CounterVec
|
||||||
|
|
||||||
ServiceReplicasGauge *prometheus.GaugeVec
|
ServiceReplicasGauge *prometheus.GaugeVec
|
||||||
ServiceMinReplicasGauge *prometheus.GaugeVec
|
|
||||||
ServiceTargetLoadGauge *prometheus.GaugeVec
|
|
||||||
|
|
||||||
ServiceMetrics *ServiceMetricOptions
|
ServiceMetrics *ServiceMetricOptions
|
||||||
}
|
}
|
||||||
@ -71,24 +69,6 @@ func BuildMetricsOptions() MetricOptions {
|
|||||||
[]string{"function_name"},
|
[]string{"function_name"},
|
||||||
)
|
)
|
||||||
|
|
||||||
serviceMinReplicas := prometheus.NewGaugeVec(
|
|
||||||
prometheus.GaugeOpts{
|
|
||||||
Namespace: "gateway",
|
|
||||||
Name: "service_min",
|
|
||||||
Help: "Minium replicas for function",
|
|
||||||
},
|
|
||||||
[]string{"function_name"},
|
|
||||||
)
|
|
||||||
|
|
||||||
serviceTargetLoad := prometheus.NewGaugeVec(
|
|
||||||
prometheus.GaugeOpts{
|
|
||||||
Namespace: "gateway",
|
|
||||||
Name: "service_target_load",
|
|
||||||
Help: "Target load for function",
|
|
||||||
},
|
|
||||||
[]string{"function_name", "scaling_type"},
|
|
||||||
)
|
|
||||||
|
|
||||||
// For automatic monitoring and alerting (RED method)
|
// For automatic monitoring and alerting (RED method)
|
||||||
histogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
histogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||||
Subsystem: "http",
|
Subsystem: "http",
|
||||||
@ -126,8 +106,6 @@ func BuildMetricsOptions() MetricOptions {
|
|||||||
GatewayFunctionsHistogram: gatewayFunctionsHistogram,
|
GatewayFunctionsHistogram: gatewayFunctionsHistogram,
|
||||||
GatewayFunctionInvocation: gatewayFunctionInvocation,
|
GatewayFunctionInvocation: gatewayFunctionInvocation,
|
||||||
ServiceReplicasGauge: serviceReplicas,
|
ServiceReplicasGauge: serviceReplicas,
|
||||||
ServiceMinReplicasGauge: serviceMinReplicas,
|
|
||||||
ServiceTargetLoadGauge: serviceTargetLoad,
|
|
||||||
ServiceMetrics: serviceMetricOptions,
|
ServiceMetrics: serviceMetricOptions,
|
||||||
GatewayFunctionInvocationStarted: gatewayFunctionInvocationStarted,
|
GatewayFunctionInvocationStarted: gatewayFunctionInvocationStarted,
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,6 @@
|
|||||||
// the OpenFaaS gateway REST API
|
// the OpenFaaS gateway REST API
|
||||||
package requests
|
package requests
|
||||||
|
|
||||||
// AsyncReport is the report from a function executed on a queue worker.
|
|
||||||
type AsyncReport struct {
|
|
||||||
FunctionName string `json:"name"`
|
|
||||||
StatusCode int `json:"statusCode"`
|
|
||||||
TimeTaken float64 `json:"timeTaken"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteFunctionRequest delete a deployed function
|
// DeleteFunctionRequest delete a deployed function
|
||||||
type DeleteFunctionRequest struct {
|
type DeleteFunctionRequest struct {
|
||||||
FunctionName string `json:"functionName"`
|
FunctionName string `json:"functionName"`
|
||||||
|
@ -28,9 +28,6 @@ type HandlerSet struct {
|
|||||||
// QueuedProxy queue work and return synchronous response
|
// QueuedProxy queue work and return synchronous response
|
||||||
QueuedProxy http.HandlerFunc
|
QueuedProxy http.HandlerFunc
|
||||||
|
|
||||||
// AsyncReport report a deferred execution result
|
|
||||||
AsyncReport http.HandlerFunc
|
|
||||||
|
|
||||||
// ScaleFunction enables a function to be scaled
|
// ScaleFunction enables a function to be scaled
|
||||||
ScaleFunction http.HandlerFunc
|
ScaleFunction http.HandlerFunc
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user