mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-18 03:28:19 +01:00
Feature: Add a metrics endpoint
Add a basic Prometheus Monitoring metrics endpoint. * Include a `jetkvm_build_info` metric. * `go mod tidy` Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
9
web.go
9
web.go
@@ -12,6 +12,10 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/prometheus/common/version"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
@@ -85,6 +89,11 @@ func setupRouter() *gin.Engine {
|
||||
// We use this to setup the device in the welcome page
|
||||
r.POST("/device/setup", handleSetup)
|
||||
|
||||
// A Prometheus metrics endpoint.
|
||||
version.Version = builtAppVersion
|
||||
prometheus.MustRegister(versioncollector.NewCollector("jetkvm"))
|
||||
r.GET("/metrics", gin.WrapH(promhttp.Handler()))
|
||||
|
||||
// Protected routes (allows both password and noPassword modes)
|
||||
protected := r.Group("/")
|
||||
protected.Use(protectedMiddleware())
|
||||
|
||||
Reference in New Issue
Block a user