mirror of
https://github.com/trafficlunar/api.git
synced 2026-06-27 22:24:08 +00:00
feat: expose prometheus metrics on different port
This commit is contained in:
parent
d93f3f2797
commit
498b45eab3
5 changed files with 19 additions and 4 deletions
14
internal/server/prometheus.go
Normal file
14
internal/server/prometheus.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
func StartPrometheusServer() {
|
||||
go func() {
|
||||
http.HandleFunc("/", promhttp.Handler().ServeHTTP)
|
||||
http.ListenAndServe(":8889", nil)
|
||||
}()
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/go-chi/cors"
|
||||
"github.com/go-chi/httprate"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
"api/internal/handler"
|
||||
app_middleware "api/internal/middleware"
|
||||
|
|
@ -49,9 +48,6 @@ func NewRouter() {
|
|||
r.Group(func(r chi.Router) {
|
||||
r.Use(app_middleware.PrometheusMiddleware)
|
||||
|
||||
// Prometheus
|
||||
r.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
var commit = "unknown"
|
||||
if os.Getenv("SOURCE_COMMIT") != "" {
|
||||
commit = os.Getenv("SOURCE_COMMIT")[:7] // shorten to 7 characters
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue