diff --git a/pkg/api/apiRouters/websocket/websocket.go b/pkg/api/apiRouters/websocket/websocket.go index 8d8534b35..1237a838f 100644 --- a/pkg/api/apiRouters/websocket/websocket.go +++ b/pkg/api/apiRouters/websocket/websocket.go @@ -1,19 +1,18 @@ - // RAINBOND, Application Management Platform // Copyright (C) 2014-2017 Goodrain Co., Ltd. - + // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. For any non-GPL usage of Rainbond, // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd. // must be obtained first. - + // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -31,6 +30,7 @@ func Routes() chi.Router { r.Get("/docker_console", controller.GetDockerConsole().Get) r.Get("/docker_log", controller.GetDockerLog().Get) r.Get("/monitor_message", controller.GetMonitorMessage().Get) + r.Get("/new_monitor_message", controller.GetMonitorMessage().Get) r.Get("/event_log", controller.GetEventLog().Get) return r } diff --git a/pkg/api/server/api.go b/pkg/api/server/api.go index c7e007974..a74c5b9fa 100644 --- a/pkg/api/server/api.go +++ b/pkg/api/server/api.go @@ -29,6 +29,7 @@ import ( "github.com/goodrain/rainbond/pkg/api/apiRouters/doc" "github.com/goodrain/rainbond/pkg/api/apiRouters/license" + "github.com/goodrain/rainbond/pkg/api/proxy" "github.com/goodrain/rainbond/pkg/api/apiRouters/cloud" "github.com/goodrain/rainbond/pkg/api/apiRouters/version2" @@ -43,11 +44,12 @@ import ( //Manager apiserver type Manager struct { - ctx context.Context - cancel context.CancelFunc - conf option.Config - stopChan chan struct{} - r *chi.Mux + ctx context.Context + cancel context.CancelFunc + conf option.Config + stopChan chan struct{} + r *chi.Mux + prometheusProxy proxy.Proxy } //NewManager newManager @@ -73,6 +75,7 @@ func NewManager(c option.Config) *Manager { //simple api version r.Use(apimiddleware.APIVersion) r.Use(apimiddleware.Proxy) + return &Manager{ ctx: ctx, cancel: cancel, @@ -118,6 +121,10 @@ func (m *Manager) Run() { m.r.Mount("/license", license.Routes()) //兼容老版docker m.r.Get("/v1/etcd/event-log/instances", m.EventLogInstance) + + //prometheus单节点代理 + m.r.Get("/api/v1/query", m.PrometheusAPI) + m.r.Get("/api/v1/query_range", m.PrometheusAPI) //开启对浏览器的websocket服务和文件服务 go func() { websocketRouter := chi.NewRouter() @@ -172,3 +179,11 @@ func (m *Manager) EventLogInstance(w http.ResponseWriter, r *http.Request) { w.WriteHeader(404) return } + +//PrometheusAPI prometheus api 代理 +func (m *Manager) PrometheusAPI(w http.ResponseWriter, r *http.Request) { + if m.prometheusProxy == nil { + m.prometheusProxy = proxy.CreateProxy("prometheus", "http", []string{"127.0.0.1:9999"}) + } + m.prometheusProxy.Proxy(w, r) +} diff --git a/test/mapper.yml b/test/mapper.yml index 978007169..66cb67903 100644 --- a/test/mapper.yml +++ b/test/mapper.yml @@ -1,16 +1,31 @@ # mappings: - match: "*.*.*.request.*" - name: "app_http_request" + name: "app_request" labels: service_id: "$1" port: "$2" protocol: $3 method: "$4" - match: "*.*.*.request.unusual.*" - name: "app_http_request_unusual" + name: "app_request_unusual" labels: service_id: "$1" port: "$2" protocol: $3 - code: "$4" \ No newline at end of file + code: "$4" + +- match: "*.*.*.requesttime.*" + name: "app_requesttime" + labels: + service_id: "$1" + port: "$2" + protocol: $3 + mode: "$4" + +- match: "*.*.*.requestclient" + name: "app_requestclient" + labels: + service_id: "$1" + port: "$2" + protocol: $3 \ No newline at end of file