Skip to content

Commit 029afb9

Browse files
author
zianazhao
committed
对齐版本
1 parent 7e58454 commit 029afb9

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

pkg/collector/handler_clb_private.go

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ var (
2323
}
2424
)
2525

26-
var (
27-
LbPrivateSupportDimensions = []string{"vip", "vpcId", "loadBalancerPort", "protocol", "lanIp", "port"}
28-
)
29-
3026
func init() {
3127
registerHandler(ClbPrivateNamespace, defaultHandlerEnabled, NewClbPrivateHandler)
3228
}
@@ -123,35 +119,32 @@ func (h *ClbPrivateHandler) GetSeriesByAll(m *metric.TcmMetric) ([]*metric.TcmSe
123119
return slist, nil
124120
}
125121

126-
func (h *ClbPrivateHandler) GetSeriesByCustom(m *metric.TcmMetric) (slist []*metric.TcmSeries, err error) {
122+
func (h *ClbPrivateHandler) GetSeriesByCustom(m *metric.TcmMetric) ([]*metric.TcmSeries, error) {
123+
var slist []*metric.TcmSeries
127124
for _, ql := range m.Conf.CustomQueryDimensions {
128-
if !h.checkMonitorQueryKeys(m, ql) {
125+
v, ok := ql[h.monitorQueryKey]
126+
if !ok {
127+
level.Error(h.logger).Log(
128+
"msg", fmt.Sprintf("not found %s in queryDimensions", h.monitorQueryKey),
129+
"ql", fmt.Sprintf("%v", ql))
129130
continue
130131
}
131-
132-
s, err := metric.NewTcmSeries(m, ql, nil)
132+
ins, err := h.collector.InstanceRepo.Get(v)
133133
if err != nil {
134-
level.Error(h.logger).Log("msg", "Create metric series fail", "metric", m.Meta.MetricName,
135-
"ql", fmt.Sprintf("%v", ql))
134+
level.Error(h.logger).Log("msg", "Instance not found", "err", err, "id", v)
136135
continue
137136
}
138-
slist = append(slist, s)
139-
}
140-
return
141-
}
142-
func (h *ClbPrivateHandler) checkMonitorQueryKeys(m *metric.TcmMetric, ql map[string]string) bool {
143-
for k := range ql {
144-
if !util.IsStrInList(LbPrivateSupportDimensions, k) {
145-
level.Error(h.logger).Log("msg", fmt.Sprintf("not found %s in supportQueryDimensions", k),
146-
"ql", fmt.Sprintf("%v", ql),
147-
"sd", fmt.Sprintf("%v", m.Meta.SupportDimensions),
148-
)
149-
return false
137+
138+
sl, err := h.getSeriesByMetricType(m, ins)
139+
if err != nil {
140+
level.Error(h.logger).Log("msg", "Create metric series fail",
141+
"metric", m.Meta.MetricName, "instacne", ins.GetInstanceId())
142+
continue
150143
}
144+
slist = append(slist, sl...)
151145
}
152-
return true
146+
return slist, nil
153147
}
154-
155148
func (h *ClbPrivateHandler) getSeriesByMetricType(m *metric.TcmMetric, ins instance.TcInstance) ([]*metric.TcmSeries, error) {
156149
var dimensions []string
157150
for _, v := range m.Meta.SupportDimensions {

0 commit comments

Comments
 (0)