Skip to content

Commit b42642a

Browse files
juexiaolinjuexiaolin
andauthored
fix: get instance more limit (#15)
* fix: get instance more limit * fix: supportDimensions missing key Co-authored-by: juexiaolin <[email protected]>
1 parent a2845c6 commit b42642a

File tree

12 files changed

+30
-5
lines changed

12 files changed

+30
-5
lines changed

configs/qcloud-cvm-product.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ products:
1111
all_instances: true
1212
#only_include_metrics: []
1313
#only_include_instances: [ins-xxxxxxxx]
14-
#extra_labels: [InstanceName]
14+
#extra_labels: [InstanceId, InstanceName]
1515
#statistics_types: [last]
1616
#period_seconds: 60
1717
#metric_name_type: 2

pkg/collector/handler_clb.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package collector
33
import (
44
"github.com/go-kit/kit/log"
55
"github.com/tencentyun/tencentcloud-exporter/pkg/metric"
6+
"github.com/tencentyun/tencentcloud-exporter/pkg/util"
67
)
78

89
const (
@@ -19,9 +20,10 @@ type clbHandler struct {
1920
}
2021

2122
func (h *clbHandler) CheckMetricMeta(meta *metric.TcmMeta) bool {
22-
if len(meta.SupportDimensions) == 0 {
23-
meta.SupportDimensions = append(meta.SupportDimensions, "vip")
23+
if !util.IsStrInList(meta.SupportDimensions, ClbInstanceidKey) {
24+
meta.SupportDimensions = append(meta.SupportDimensions, ClbInstanceidKey)
2425
}
26+
2527
return true
2628
}
2729

pkg/collector/handler_clb7.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ type clb7Handler struct {
3333
}
3434

3535
func (h *clb7Handler) CheckMetricMeta(meta *metric.TcmMeta) bool {
36-
meta.SupportDimensions = append(meta.SupportDimensions, "vip")
36+
if !util.IsStrInList(meta.SupportDimensions, Clb7InstanceidKey) {
37+
meta.SupportDimensions = append(meta.SupportDimensions, Clb7InstanceidKey)
38+
}
39+
3740
return true
3841
}
3942

pkg/collector/handler_cvm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ type cvmHandler struct {
2525
}
2626

2727
func (h *cvmHandler) CheckMetricMeta(meta *metric.TcmMeta) bool {
28+
if !util.IsStrInList(meta.SupportDimensions, CvmInstanceidKey) {
29+
meta.SupportDimensions = append(meta.SupportDimensions, CvmInstanceidKey)
30+
}
31+
2832
return true
2933
}
3034

pkg/instance/repository_cdb.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (repo *CdbTcInstanceRepository) ListByFilters(filters map[string]string) (i
5050
var limit uint64 = 2000
5151
var total int64 = -1
5252

53+
req.Offset = &offset
5354
req.Limit = &limit
5455

5556
getMoreInstances:
@@ -70,6 +71,7 @@ getMoreInstances:
7071
}
7172
offset += limit
7273
if offset < uint64(total) {
74+
req.Offset = &offset
7375
goto getMoreInstances
7476
}
7577

pkg/instance/repository_clb.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func (repo *ClbTcInstanceRepository) ListByFilters(filters map[string]string) (i
6363
var offset int64 = 0
6464
var limit int64 = 100
6565
var total int64 = -1
66+
67+
req.Offset = &offset
6668
req.Limit = &limit
6769

6870
getMoreInstances:
@@ -83,6 +85,7 @@ getMoreInstances:
8385
}
8486
offset += limit
8587
if offset < total {
88+
req.Offset = &offset
8689
goto getMoreInstances
8790
}
8891

pkg/instance/repository_cvm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (repo *CvmTcInstanceRepository) ListByFilters(filters map[string]string) (i
5050
var limit int64 = 100
5151
var total int64 = -1
5252

53+
req.Offset = &offset
5354
req.Limit = &limit
5455

5556
getMoreInstances:
@@ -70,6 +71,7 @@ getMoreInstances:
7071
}
7172
offset += limit
7273
if offset < total {
74+
req.Offset = &offset
7375
goto getMoreInstances
7476
}
7577
return

pkg/instance/repository_dc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (repo *DcTcInstanceRepository) ListByFilters(filters map[string]string) (in
5050
var limit int64 = 100
5151
var total int64 = -1
5252

53+
req.Offset = &offset
5354
req.Limit = &limit
5455

5556
getMoreInstances:
@@ -70,6 +71,7 @@ getMoreInstances:
7071
}
7172
offset += limit
7273
if offset < total {
74+
req.Offset = &offset
7375
goto getMoreInstances
7476
}
7577

pkg/instance/repository_dcx.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func (repo *DcxTcInstanceRepository) ListByFilters(filters map[string]string) (i
4949
var offset int64 = 0
5050
var limit int64 = 100
5151
var total int64 = -1
52+
req.Offset = &offset
5253
req.Limit = &limit
5354

5455
getMoreInstances:
@@ -69,6 +70,7 @@ getMoreInstances:
6970
}
7071
offset += limit
7172
if offset < total {
73+
req.Offset = &offset
7274
goto getMoreInstances
7375
}
7476

pkg/instance/repository_mongo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func (repo *MongoTcInstanceRepository) ListByFilters(filters map[string]string)
5151
var limit uint64 = 100
5252
var total int64 = -1
5353

54+
req.Offset = &offset
5455
req.Limit = &limit
5556

5657
if v, ok := filters["ProjectId"]; ok {
@@ -82,6 +83,7 @@ getMoreInstances:
8283
}
8384
offset += limit
8485
if offset < uint64(total) {
86+
req.Offset = &offset
8587
goto getMoreInstances
8688
}
8789

0 commit comments

Comments
 (0)