diff --git a/monitor/callback/node.go b/monitor/callback/node.go index 806bbf2c9..87dc359bd 100644 --- a/monitor/callback/node.go +++ b/monitor/callback/node.go @@ -19,14 +19,15 @@ package callback import ( + "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/util/watch" "github.com/goodrain/rainbond/monitor/utils" + "github.com/goodrain/rainbond/util/watch" "github.com/prometheus/common/model" - "time" "github.com/tidwall/gjson" ) @@ -90,7 +91,7 @@ func (e *Node) AddEndpoint(end *config.Endpoint) { } func (e *Node) Add(event *watch.Event) { - url := gjson.Get(event.GetValueString(), "external_ip").String() + ":6100" + url := gjson.Get(event.GetValueString(), "internal_ip").String() + ":6100" end := &config.Endpoint{ URL: url, } @@ -101,7 +102,7 @@ func (e *Node) Add(event *watch.Event) { func (e *Node) Modify(event *watch.Event) { for i, end := range e.endpoints { if end.URL == event.GetValueString() { - url := gjson.Get(event.GetValueString(), "external_ip").String() + ":6100" + url := gjson.Get(event.GetValueString(), "internal_ip").String() + ":6100" e.endpoints[i].URL = url e.UpdateEndpoints(e.endpoints...) break @@ -111,7 +112,7 @@ func (e *Node) Modify(event *watch.Event) { func (e *Node) Delete(event *watch.Event) { for i, end := range e.endpoints { - url := gjson.Get(event.GetValueString(), "external_ip").String() + ":6100" + url := gjson.Get(event.GetValueString(), "internal_ip").String() + ":6100" if end.URL == url { e.endpoints = append(e.endpoints[:i], e.endpoints[i+1:]...) e.UpdateEndpoints(e.endpoints...) diff --git a/monitor/monitor.go b/monitor/monitor.go index fe338cc86..a73a21d3a 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -34,6 +34,7 @@ import ( "github.com/tidwall/gjson" ) +//Monitor monitor type Monitor struct { config *option.Config ctx context.Context @@ -45,13 +46,13 @@ type Monitor struct { discoverv2 discoverv2.Discover } +//Start start func (d *Monitor) Start() { d.discoverv1.AddProject("prometheus", &callback.Prometheus{Prometheus: d.manager}) d.discoverv1.AddProject("event_log_event_http", &callback.EventLog{Prometheus: d.manager}) d.discoverv1.AddProject("acp_entrance", &callback.Entrance{Prometheus: d.manager}) - d.discoverv2.AddProject("app_sync_runtime_server", &callback.AppStatus{Prometheus: d.manager}) + d.discoverv1.AddProject("acp_webcli", &callback.Webcli{Prometheus: d.manager}) d.discoverv2.AddProject("builder", &callback.Builder{Prometheus: d.manager}) - d.discoverv2.AddProject("acp_webcli", &callback.Webcli{Prometheus: d.manager}) d.discoverv2.AddProject("mq", &callback.Mq{Prometheus: d.manager}) // node and app runtime metrics needs to be monitored separately @@ -181,11 +182,13 @@ func (d *Monitor) discoverEtcd(e *callback.Etcd, done <-chan struct{}) { endpoints := make([]*config.Endpoint, 0, 5) for _, member := range resp.Members { - url := member.GetName() + ":2379" - end := &config.Endpoint{ - URL: url, + if len(member.ClientURLs) > 1 { + url := member.ClientURLs[0] + end := &config.Endpoint{ + URL: url, + } + endpoints = append(endpoints, end) } - endpoints = append(endpoints, end) } e.UpdateEndpoints(endpoints...)