diff --git a/configs/qcloud-cvm-product.yml b/configs/qcloud-cvm-product.yml index 883e7fa..216f844 100644 --- a/configs/qcloud-cvm-product.yml +++ b/configs/qcloud-cvm-product.yml @@ -11,7 +11,7 @@ products: all_instances: true #only_include_metrics: [] #only_include_instances: [ins-xxxxxxxx] - #extra_labels: [InstanceName] + #extra_labels: [InstanceId, InstanceName] #statistics_types: [last] #period_seconds: 60 #metric_name_type: 2 diff --git a/pkg/collector/handler_clb.go b/pkg/collector/handler_clb.go index 6ee0d97..ae6af99 100644 --- a/pkg/collector/handler_clb.go +++ b/pkg/collector/handler_clb.go @@ -3,6 +3,7 @@ package collector import ( "github.com/go-kit/kit/log" "github.com/tencentyun/tencentcloud-exporter/pkg/metric" + "github.com/tencentyun/tencentcloud-exporter/pkg/util" ) const ( @@ -19,9 +20,10 @@ type clbHandler struct { } func (h *clbHandler) CheckMetricMeta(meta *metric.TcmMeta) bool { - if len(meta.SupportDimensions) == 0 { - meta.SupportDimensions = append(meta.SupportDimensions, "vip") + if !util.IsStrInList(meta.SupportDimensions, ClbInstanceidKey) { + meta.SupportDimensions = append(meta.SupportDimensions, ClbInstanceidKey) } + return true } diff --git a/pkg/collector/handler_clb7.go b/pkg/collector/handler_clb7.go index 3acc660..087a252 100644 --- a/pkg/collector/handler_clb7.go +++ b/pkg/collector/handler_clb7.go @@ -33,7 +33,10 @@ type clb7Handler struct { } func (h *clb7Handler) CheckMetricMeta(meta *metric.TcmMeta) bool { - meta.SupportDimensions = append(meta.SupportDimensions, "vip") + if !util.IsStrInList(meta.SupportDimensions, Clb7InstanceidKey) { + meta.SupportDimensions = append(meta.SupportDimensions, Clb7InstanceidKey) + } + return true } diff --git a/pkg/collector/handler_cvm.go b/pkg/collector/handler_cvm.go index 61696fd..78a2bec 100644 --- a/pkg/collector/handler_cvm.go +++ b/pkg/collector/handler_cvm.go @@ -25,6 +25,10 @@ type cvmHandler struct { } func (h *cvmHandler) CheckMetricMeta(meta *metric.TcmMeta) bool { + if !util.IsStrInList(meta.SupportDimensions, CvmInstanceidKey) { + meta.SupportDimensions = append(meta.SupportDimensions, CvmInstanceidKey) + } + return true } diff --git a/pkg/instance/repository_cdb.go b/pkg/instance/repository_cdb.go index 4efaff7..81d2852 100644 --- a/pkg/instance/repository_cdb.go +++ b/pkg/instance/repository_cdb.go @@ -50,6 +50,7 @@ func (repo *CdbTcInstanceRepository) ListByFilters(filters map[string]string) (i var limit uint64 = 2000 var total int64 = -1 + req.Offset = &offset req.Limit = &limit getMoreInstances: @@ -70,6 +71,7 @@ getMoreInstances: } offset += limit if offset < uint64(total) { + req.Offset = &offset goto getMoreInstances } diff --git a/pkg/instance/repository_clb.go b/pkg/instance/repository_clb.go index 8bb1dcb..0aa0646 100644 --- a/pkg/instance/repository_clb.go +++ b/pkg/instance/repository_clb.go @@ -63,6 +63,8 @@ func (repo *ClbTcInstanceRepository) ListByFilters(filters map[string]string) (i var offset int64 = 0 var limit int64 = 100 var total int64 = -1 + + req.Offset = &offset req.Limit = &limit getMoreInstances: @@ -83,6 +85,7 @@ getMoreInstances: } offset += limit if offset < total { + req.Offset = &offset goto getMoreInstances } diff --git a/pkg/instance/repository_cvm.go b/pkg/instance/repository_cvm.go index 5348fa5..c97646c 100644 --- a/pkg/instance/repository_cvm.go +++ b/pkg/instance/repository_cvm.go @@ -50,6 +50,7 @@ func (repo *CvmTcInstanceRepository) ListByFilters(filters map[string]string) (i var limit int64 = 100 var total int64 = -1 + req.Offset = &offset req.Limit = &limit getMoreInstances: @@ -70,6 +71,7 @@ getMoreInstances: } offset += limit if offset < total { + req.Offset = &offset goto getMoreInstances } return diff --git a/pkg/instance/repository_dc.go b/pkg/instance/repository_dc.go index 106a387..2d16406 100644 --- a/pkg/instance/repository_dc.go +++ b/pkg/instance/repository_dc.go @@ -50,6 +50,7 @@ func (repo *DcTcInstanceRepository) ListByFilters(filters map[string]string) (in var limit int64 = 100 var total int64 = -1 + req.Offset = &offset req.Limit = &limit getMoreInstances: @@ -70,6 +71,7 @@ getMoreInstances: } offset += limit if offset < total { + req.Offset = &offset goto getMoreInstances } diff --git a/pkg/instance/repository_dcx.go b/pkg/instance/repository_dcx.go index 83428b8..2cafeec 100644 --- a/pkg/instance/repository_dcx.go +++ b/pkg/instance/repository_dcx.go @@ -49,6 +49,7 @@ func (repo *DcxTcInstanceRepository) ListByFilters(filters map[string]string) (i var offset int64 = 0 var limit int64 = 100 var total int64 = -1 + req.Offset = &offset req.Limit = &limit getMoreInstances: @@ -69,6 +70,7 @@ getMoreInstances: } offset += limit if offset < total { + req.Offset = &offset goto getMoreInstances } diff --git a/pkg/instance/repository_mongo.go b/pkg/instance/repository_mongo.go index 7b54f6d..1fde56e 100644 --- a/pkg/instance/repository_mongo.go +++ b/pkg/instance/repository_mongo.go @@ -51,6 +51,7 @@ func (repo *MongoTcInstanceRepository) ListByFilters(filters map[string]string) var limit uint64 = 100 var total int64 = -1 + req.Offset = &offset req.Limit = &limit if v, ok := filters["ProjectId"]; ok { @@ -82,6 +83,7 @@ getMoreInstances: } offset += limit if offset < uint64(total) { + req.Offset = &offset goto getMoreInstances } diff --git a/pkg/instance/repository_nat.go b/pkg/instance/repository_nat.go index c950cfa..70b3578 100644 --- a/pkg/instance/repository_nat.go +++ b/pkg/instance/repository_nat.go @@ -49,6 +49,7 @@ func (repo *NatTcInstanceRepository) ListByFilters(filters map[string]string) (i var offset uint64 = 0 var limit uint64 = 100 var total int64 = -1 + req.Offset = &offset req.Limit = &limit getMoreInstances: @@ -69,6 +70,7 @@ getMoreInstances: } offset += limit if offset < uint64(total) { + req.Offset = &offset goto getMoreInstances } return diff --git a/pkg/instance/repository_redis.go b/pkg/instance/repository_redis.go index 92a0f2b..b92a526 100644 --- a/pkg/instance/repository_redis.go +++ b/pkg/instance/repository_redis.go @@ -49,7 +49,7 @@ func (repo *RedisTcInstanceRepository) ListByFilters(filters map[string]string) var offset uint64 = 0 var limit uint64 = 100 var total int64 = -1 - + req.Offset = &offset req.Limit = &limit getMoreInstances: @@ -70,6 +70,7 @@ getMoreInstances: } offset += limit if offset < uint64(total) { + req.Offset = &offset goto getMoreInstances }