refactoring monitor code, support prometheus (#1668)

* refactoring monitor code, support prometheus
* remove vendor
This commit is contained in:
fatedier
2020-03-11 13:20:26 +08:00
committed by GitHub
parent 6d1af85e80
commit 495d999b6c
889 changed files with 682 additions and 333140 deletions

View File

@@ -24,6 +24,7 @@ import (
frpNet "github.com/fatedier/frp/utils/net"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
@@ -38,6 +39,11 @@ func (svr *Service) RunDashboardServer(addr string, port int) (err error) {
user, passwd := svr.cfg.DashboardUser, svr.cfg.DashboardPwd
router.Use(frpNet.NewHttpAuthMiddleware(user, passwd).Middleware)
// metrics
if svr.cfg.EnablePrometheus {
router.Handle("/metrics", promhttp.Handler())
}
// api, see dashboard_api.go
router.HandleFunc("/api/serverinfo", svr.ApiServerInfo).Methods("GET")
router.HandleFunc("/api/proxy/{type}", svr.ApiProxyByType).Methods("GET")