mirror of https://github.com/jetkvm/kvm.git
chore(prometheus): move prometheus to a new file
This commit is contained in:
parent
5c7accae0d
commit
8b59a3e387
2
main.go
2
main.go
|
@ -36,6 +36,8 @@ func Main() {
|
|||
StartNativeCtrlSocketServer()
|
||||
StartNativeVideoSocketServer()
|
||||
|
||||
initPrometheus()
|
||||
|
||||
go func() {
|
||||
err = ExtractAndRunNativeBin()
|
||||
if err != nil {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package kvm
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version"
|
||||
"github.com/prometheus/common/version"
|
||||
)
|
||||
|
||||
var promHandler http.Handler
|
||||
|
||||
func initPrometheus() {
|
||||
// A Prometheus metrics endpoint.
|
||||
version.Version = builtAppVersion
|
||||
prometheus.MustRegister(versioncollector.NewCollector("jetkvm"))
|
||||
}
|
5
web.go
5
web.go
|
@ -12,10 +12,7 @@ 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"
|
||||
)
|
||||
|
||||
|
@ -90,8 +87,6 @@ func setupRouter() *gin.Engine {
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue