Skip to content

Commit ff23178

Browse files
authored
Merge branch 'master' into dev/gaap
2 parents 00ac9dd + 42c2487 commit ff23178

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ CYNOSDB_MYSQL|QCE/CYNOSDB_MYSQL|[指标详情](https://cloud.tencent.com/documen
4444
云联网|QCE/VBC|[指标详情](https://cloud.tencent.com/document/product/248/75629)
4545
数据传输 |QCE/DTS|指标详情说明文档(待上线)
4646
专线网关 |QCE/DCG|指标详情说明文档(待上线)
47+
全球应用加速|QCE/QAAP|[指标详情](https://cloud.tencent.com/document/product/248/45062)
4748

4849
`后续会有更多的产品支持`
4950

@@ -89,29 +90,26 @@ products:
8990
```yaml
9091
credential:
9192
access_key: <YOUR_ACCESS_KEY> // 必须, 云API的SecretId
92-
secret_key: <YOUR_ACCESS_SECRET> // 必须, 云API的SecretKey
93+
secret_key: <YOUR_ACCESS_SECRET> // 必须, 云API的SecretKey
9394
region: <REGION> // 必须, 实例所在区域信息
9495

9596
rate_limit: 15 // 腾讯云监控拉取指标数据限制, 官方默认限制最大20qps
9697

9798

9899
// 整个产品纬度配置, 每个产品一个item
99100
products:
100-
- namespace: QCE/CMONGO // 必须, 产品命名空间; QCE前缀可自定义,CMONGO产品名不区分大小写, 可用别名
101+
- namespace: QCE/CMONGO // 必须, 产品命名空间
101102
all_metrics: true // 常用, 推荐开启, 导出支持的所有指标
102103
all_instances: true // 常用, 推荐开启, 导出该region下的所有实例
103104
extra_labels: [InstanceName,Zone] // 可选, 将实例的字段作为指标的lables导出
104105
only_include_metrics: [Inserts] // 可选, 只导出这些指标, 配置时all_metrics失效
105106
exclude_metrics: [Reads] // 可选, 不导出这些指标
106-
instance_filters: // 可选, 在all_instances开启情况下, 根据每个实例的字段进行过滤
107-
- ProjectId: 1
108-
Status: 1
109107
only_include_instances: [cmgo-xxxxxxxx] // 可选, 只导出这些实例id, 配置时all_instances失效
110108
exclude_instances: [cmgo-xxxxxxxx] // 可选, 不导出这些实例id
111109
custom_query_dimensions: // 可选, 不常用, 自定义指标查询条件, 配置时all_instances,only_include_instances,exclude_instances失效, 用于不支持按实例纬度查询的指标
112110
- target: cmgo-xxxxxxxx
113111
statistics_types: [avg] // 可选, 拉取N个数据点, 再进行max、min、avg、last计算, 默认last取最新值
114-
period_seconds: 60 // 可选, 指标统计周期, 默认自动获取指标支持的最小统计周期
112+
period_seconds: 60 // 可选, 指标统计周期
115113
range_seconds: 300 // 可选, 选取时间范围, 开始时间=now-range_seconds, 结束时间=now
116114
delay_seconds: 60 // 可选, 时间偏移量, 结束时间=now-delay_seconds
117115
metric_name_type: 1 // 可选,导出指标的名字格式化类型, 1=大写转小写加下划线, 2=转小写; 默认2
@@ -125,9 +123,6 @@ metrics:
125123
tc_metric_rename: Inserts // 导出指标的显示名
126124
tc_metric_name_type: 1 // 可选,导出指标的名字格式化类型, 1=大写转小写加下划线, 2=转小写; 默认1
127125
tc_labels: [InstanceName] // 可选, 将实例的字段作为指标的lables导出
128-
tc_filters: // 可选, 根据每个实例的字段进行过滤, 否则默认导出region下所有实例
129-
- ProjectId: 1
130-
Status: 1
131126
tc_myself_dimensions: // 可选, 同custom_query_dimensions
132127
tc_statistics: [Avg] // 可选, 同statistics_types
133128
period_seconds: 60 // 可选, 同period_seconds

pkg/metric/repository.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ func (repo *TcmMetricRepositoryImpl) listSampleByBatch(
192192
if repo.IsInternational && m.Meta.ProductName == "QAAP" {
193193
response, err = repo.monitorClientInSinapore.GetMonitorData(request)
194194
} else if util.IsStrInList(config.QcloudNamespace, m.Meta.ProductName) {
195+
response, err = repo.monitorClientInGuangzhou.GetMonitorData(request)
196+
} else {
195197
response, err = repo.monitorClient.GetMonitorData(request)
196198
}
197199
if err != nil {
@@ -291,6 +293,7 @@ func NewTcmMetricRepository(cred common.CredentialIface, conf *config.TencentCon
291293
return
292294
}
293295
}
296+
294297
repo = &TcmMetricRepositoryImpl{
295298
credential: cred,
296299
monitorClient: monitorClient,

pkg/util/label.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"unicode"
66
)
77

8+
// IsValidTagKey ref: https://cloud.tencent.com/document/product/1416/73370#.E8.87.AA.E5.AE.9A.E4.B9.89.E4.B8.8A.E6.8A.A5.E9.99.90.E5.88.B6
89
func IsValidTagKey(str string) bool {
910
for _, r := range str {
1011
if unicode.Is(unicode.Scripts["Han"], r) || (regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]").MatchString(string(r))) {
1112
return false
1213
}
1314
}
14-
if !regexp.MustCompile(`^[A-Za-z0-9_]+$`).MatchString(str) {
15+
if !regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*$`).MatchString(str) || len(str) > 1024 {
1516
return false
1617
}
1718
return true

pkg/util/label_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package util
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func Test_IsValidTagKey(t *testing.T) {
10+
res := IsValidTagKey("test-test")
11+
assert.False(t, res)
12+
res = IsValidTagKey("_4324hdj_fas213")
13+
assert.True(t, res)
14+
res = IsValidTagKey("4324hdj_fas213")
15+
assert.False(t, res)
16+
res = IsValidTagKey("是3213dsa")
17+
assert.False(t, res)
18+
res = IsValidTagKey("cls-xxxx-eks-eip-tag-pod-uid")
19+
assert.False(t, res)
20+
}

0 commit comments

Comments
 (0)