mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 08:46:48 +00:00
Add new HTTPServer to serve /metrics on port 8082
This commit runs a new HTTPServer on port 8082 in a goroutine to serve /metrics endpoint on a different port. This also update the configurations and compose files. Fixes: #1081 Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
This commit is contained in:
parent
aeb4eb9993
commit
90ddd56985
@ -3,6 +3,7 @@ services:
|
|||||||
gateway:
|
gateway:
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
|
- 8082:8082
|
||||||
image: openfaas/gateway:0.11.0-arm64
|
image: openfaas/gateway:0.11.0-arm64
|
||||||
networks:
|
networks:
|
||||||
- functions
|
- functions
|
||||||
|
@ -3,6 +3,7 @@ services:
|
|||||||
gateway:
|
gateway:
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
|
- 8082:8082
|
||||||
image: openfaas/gateway:0.11.0-armhf
|
image: openfaas/gateway:0.11.0-armhf
|
||||||
networks:
|
networks:
|
||||||
- functions
|
- functions
|
||||||
|
@ -3,6 +3,7 @@ services:
|
|||||||
gateway:
|
gateway:
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
|
- 8082:8082
|
||||||
image: openfaas/gateway:0.11.1
|
image: openfaas/gateway:0.11.1
|
||||||
networks:
|
networks:
|
||||||
- functions
|
- functions
|
||||||
|
@ -48,6 +48,7 @@ RUN addgroup -S app \
|
|||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
EXPOSE 8082
|
||||||
ENV http_proxy ""
|
ENV http_proxy ""
|
||||||
ENV https_proxy ""
|
ENV https_proxy ""
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ RUN addgroup -S app \
|
|||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
EXPOSE 8082
|
||||||
ENV http_proxy ""
|
ENV http_proxy ""
|
||||||
ENV https_proxy ""
|
ENV https_proxy ""
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ RUN addgroup -S app \
|
|||||||
WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
EXPOSE 8082
|
||||||
ENV http_proxy ""
|
ENV http_proxy ""
|
||||||
ENV https_proxy ""
|
ENV https_proxy ""
|
||||||
|
|
||||||
|
@ -207,7 +207,22 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
metricsHandler := metrics.PrometheusHandler()
|
metricsHandler := metrics.PrometheusHandler()
|
||||||
r.Handle("/metrics", metricsHandler)
|
|
||||||
|
//Create a new server to serve /metrics endpoint
|
||||||
|
go func() {
|
||||||
|
routes := mux.NewRouter()
|
||||||
|
routes.Handle("/metrics", metricsHandler)
|
||||||
|
port := 8082
|
||||||
|
s := &http.Server{
|
||||||
|
Addr: fmt.Sprintf(":%d", port),
|
||||||
|
ReadTimeout: config.ReadTimeout,
|
||||||
|
WriteTimeout: config.WriteTimeout,
|
||||||
|
MaxHeaderBytes: http.DefaultMaxHeaderBytes,
|
||||||
|
Handler: routes,
|
||||||
|
}
|
||||||
|
log.Fatal(s.ListenAndServe())
|
||||||
|
}()
|
||||||
|
|
||||||
r.HandleFunc("/healthz", handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)).Methods(http.MethodGet)
|
r.HandleFunc("/healthz", handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)).Methods(http.MethodGet)
|
||||||
|
|
||||||
r.Handle("/", http.RedirectHandler("/ui/", http.StatusMovedPermanently)).Methods(http.MethodGet)
|
r.Handle("/", http.RedirectHandler("/ui/", http.StatusMovedPermanently)).Methods(http.MethodGet)
|
||||||
|
@ -32,6 +32,6 @@ scrape_configs:
|
|||||||
scrape_interval: 5s
|
scrape_interval: 5s
|
||||||
dns_sd_configs:
|
dns_sd_configs:
|
||||||
- names: ['gateway.default.svc.cluster.local']
|
- names: ['gateway.default.svc.cluster.local']
|
||||||
port: 8080
|
port: 8082
|
||||||
type: A
|
type: A
|
||||||
refresh_interval: 5s
|
refresh_interval: 5s
|
||||||
|
@ -32,7 +32,7 @@ scrape_configs:
|
|||||||
scrape_interval: 5s
|
scrape_interval: 5s
|
||||||
dns_sd_configs:
|
dns_sd_configs:
|
||||||
- names: ['tasks.gateway']
|
- names: ['tasks.gateway']
|
||||||
port: 8080
|
port: 8082
|
||||||
type: A
|
type: A
|
||||||
refresh_interval: 5s
|
refresh_interval: 5s
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user