diff --git a/monitor/callback/appstatus.go b/monitor/callback/appstatus.go index db8c024e6..72cf68dc6 100644 --- a/monitor/callback/appstatus.go +++ b/monitor/callback/appstatus.go @@ -19,26 +19,28 @@ package callback import ( + "strings" + "time" + "github.com/Sirupsen/logrus" "github.com/goodrain/rainbond/discover" "github.com/goodrain/rainbond/discover/config" "github.com/goodrain/rainbond/monitor/prometheus" "github.com/goodrain/rainbond/monitor/utils" "github.com/prometheus/common/model" - "time" - "strings" "github.com/tidwall/gjson" ) -// AppStatus 指app性能数据,被选举为leader的worker,也就是app_sync_runtime_server所在的节点 +// Worker worker monitor // 127.0.0.1:6369/metrics -type AppStatus struct { +type Worker struct { discover.Callback Prometheus *prometheus.Manager sortedEndpoints []string } -func (e *AppStatus) UpdateEndpoints(endpoints ...*config.Endpoint) { +//UpdateEndpoints update endpoint +func (e *Worker) UpdateEndpoints(endpoints ...*config.Endpoint) { // 用v3 API注册,返回json格试,所以要提前处理一下 newEndpoints := make([]*config.Endpoint, 0, len(endpoints)) for _, end := range endpoints { @@ -68,15 +70,16 @@ func (e *AppStatus) UpdateEndpoints(endpoints ...*config.Endpoint) { e.Prometheus.UpdateScrape(scrape) } -func (e *AppStatus) Error(err error) { +func (e *Worker) Error(err error) { logrus.Error(err) } -func (e *AppStatus) Name() string { - return "app_status" +//Name return name +func (e *Worker) Name() string { + return "worker" } -func (e *AppStatus) toScrape() *prometheus.ScrapeConfig { +func (e *Worker) toScrape() *prometheus.ScrapeConfig { ts := make([]string, 0, len(e.sortedEndpoints)) for _, end := range e.sortedEndpoints { ts = append(ts, end) @@ -92,7 +95,7 @@ func (e *AppStatus) toScrape() *prometheus.ScrapeConfig { { Targets: ts, Labels: map[model.LabelName]model.LabelValue{ - "component": model.LabelValue(e.Name()), + "component": model.LabelValue(e.Name()), "service_name": model.LabelValue(e.Name()), }, }, diff --git a/monitor/monitor.go b/monitor/monitor.go index 6c97ee696..566ae393a 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -54,6 +54,7 @@ func (d *Monitor) Start() { d.discoverv1.AddProject("acp_webcli", &callback.Webcli{Prometheus: d.manager}) d.discoverv2.AddProject("builder", &callback.Builder{Prometheus: d.manager}) d.discoverv2.AddProject("mq", &callback.Mq{Prometheus: d.manager}) + d.discoverv2.AddProject("app_sync_runtime_server", &callback.Worker{Prometheus: d.manager}) // node and app runtime metrics needs to be monitored separately go d.discoverNodes(&callback.Node{Prometheus: d.manager}, &callback.App{Prometheus: d.manager}, d.ctx.Done())