Skip to content

Commit

Permalink
v2.1.2 (#18)
Browse files Browse the repository at this point in the history
* fix: get instance more limit

* fix: supportDimensions missing key

* fix(cache): get metric from cache nil

* fix(dcx): skip invalid metric

Co-authored-by: juexiaolin <[email protected]>
  • Loading branch information
juexiaolin and juexiaolin authored Nov 10, 2020
1 parent b42642a commit f9a5d8e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 9 additions & 0 deletions pkg/collector/handler_dcx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ package collector
import (
"github.com/go-kit/kit/log"
"github.com/tencentyun/tencentcloud-exporter/pkg/metric"
"github.com/tencentyun/tencentcloud-exporter/pkg/util"
"strings"
)

const (
DcxNamespace = "QCE/DCX"
DcxInstanceidKey = "directConnectConnId"
)

var (
DcxInvalidMetricNames = []string{"rxbytes", "txbytes"}
)

func init() {
registerHandler(DcxNamespace, defaultHandlerEnabled, NewDcxHandler)
}
Expand All @@ -19,6 +25,9 @@ type dcxHandler struct {
}

func (h *dcxHandler) CheckMetricMeta(meta *metric.TcmMeta) bool {
if util.IsStrInList(DcxInvalidMetricNames, strings.ToLower(meta.MetricName)) {
return false
}
return true
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/collector/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (c *TcProductCollector) loadMetricsByProductConf() (err error) {
}
// 指标元数据处理, false=跳过
if !c.handler.CheckMetricMeta(meta) {
level.Error(c.logger).Log("msg", " Metric meta check fail, skip", "Namespace", c.Namespace, "name", meta.MetricName)
level.Warn(c.logger).Log("msg", " Metric not support, skip", "Namespace", c.Namespace, "name", meta.MetricName)
continue
}

Expand All @@ -143,7 +143,7 @@ func (c *TcProductCollector) loadMetricsByProductConf() (err error) {
}
// 指标过滤
if !c.handler.IsIncludeMetric(nm) {
level.Error(c.logger).Log("msg", " Metric not support, skip", "Namespace", c.Namespace, "name", nm.Meta.MetricName)
level.Warn(c.logger).Log("msg", " Metric not support, skip", "Namespace", c.Namespace, "name", nm.Meta.MetricName)
continue
}
c.MetricMap[meta.MetricName] = nm
Expand Down
11 changes: 10 additions & 1 deletion pkg/metric/cache.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package metric

import (
"fmt"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"strings"
Expand All @@ -20,7 +21,15 @@ func (c *TcmMetricCache) GetMeta(namespace string, name string) (*TcmMeta, error
if err != nil {
return nil, err
}
return c.metaCache[namespace][strings.ToLower(name)], nil
np, exists := c.metaCache[namespace]
if !exists {
return nil, fmt.Errorf("namespace cache not exists")
}
m, exists := np[strings.ToLower(name)]
if !exists {
return nil, fmt.Errorf("metric cache not exists")
}
return m, nil
}

func (c *TcmMetricCache) ListMetaByNamespace(namespace string) ([]*TcmMeta, error) {
Expand Down

0 comments on commit f9a5d8e

Please sign in to comment.