Skip to content

Commit

Permalink
Merge pull request #98 from zianazhao/dev/timeZone
Browse files Browse the repository at this point in the history
feat
  • Loading branch information
zero3233 authored Feb 7, 2023
2 parents 6f6e634 + deb919a commit cf5201f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 34 deletions.
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,41 @@

产品 | 命名空间 |支持的指标|
--------|---------|----------
MongoDB |QCE/CMONGO|[指标详情](https://cloud.tencent.com/document/product/248/45104)
CDB|QCE/CDB|[指标详情](https://cloud.tencent.com/document/product/248/45147)
数据库MongoDB |QCE/CMONGO|[指标详情](https://cloud.tencent.com/document/product/248/45104)
数据库MySQL(CDB)|QCE/CDB|[指标详情](https://cloud.tencent.com/document/product/248/45147)
Redis标准版|QCE/REDIS(即将下线,不推荐)|[指标详情](https://cloud.tencent.com/document/product/248/45111)
Redis集群版|QCE/REDIS_CLUSTER(即将下线,不推荐)|[指标详情](https://cloud.tencent.com/document/product/248/45111)
Redis内存版监控指标|QCE/REDIS_MEM|[指标详情](https://cloud.tencent.com/document/product/248/49729)
CVM|QCE/CVM|[指标详情](https://cloud.tencent.com/document/product/248/6843)
数据库Redis(内存版)|QCE/REDIS_MEM|[指标详情](https://cloud.tencent.com/document/product/248/49729)
云服务器CVM|QCE/CVM|[指标详情](https://cloud.tencent.com/document/product/248/6843)
COS|QCE/COS|[指标详情](https://cloud.tencent.com/document/product/248/45140)
CDN|QCE/CDN|[指标详情](https://cloud.tencent.com/document/product/248/45138)
CLB(公网)|QCE/LB_PUBLIC|[指标详情](https://cloud.tencent.com/document/product/248/45047)
CLB(7层)|QCE/LOADBALANCE|[指标详情](https://cloud.tencent.com/document/product/248/45045)
NAT|QCE/NAT_GATEWAY|[指标详情](https://cloud.tencent.com/document/product/248/45069)
负载均衡CLB(公网)|QCE/LB_PUBLIC|[指标详情](https://cloud.tencent.com/document/product/248/45047)
负载均衡CLB(7层)|QCE/LOADBALANCE|[指标详情](https://cloud.tencent.com/document/product/248/45045)
NAT网关|QCE/NAT_GATEWAY|[指标详情](https://cloud.tencent.com/document/product/248/45069)
物理专线|QCE/DC|[指标详情](https://cloud.tencent.com/document/product/248/45102)
专用通道|QCE/DCX|[指标详情](https://cloud.tencent.com/document/product/248/45101)
云硬盘|QCE/CBS|[指标详情](https://cloud.tencent.com/document/product/248/45411)
SqlServer|QCE/SQLSERVER|[指标详情](https://cloud.tencent.com/document/product/248/45146)
MariaDB|QCE/MARIADB|[指标详情](https://cloud.tencent.com/document/product/248/54397)
数据库SQL Server|QCE/SQLSERVER|[指标详情](https://cloud.tencent.com/document/product/248/45146)
数据库MariaDB|QCE/MARIADB|[指标详情](https://cloud.tencent.com/document/product/248/54397)
Elasticsearch|QCE/CES|[指标详情](https://cloud.tencent.com/document/product/248/45129)
CMQ 队列服务|QCE/CMQ(即将下线,不推荐)|[指标详情](https://cloud.tencent.com/document/product/248/45114)
CMQ 主题订阅|QCE/CMQTOPIC(即将下线,不推荐)|[指标详情](https://cloud.tencent.com/document/product/248/45113)
PostgreSQL|QCE/POSTGRES|[指标详情](https://cloud.tencent.com/document/product/248/45105)
数据库PostgreSQL|QCE/POSTGRES|[指标详情](https://cloud.tencent.com/document/product/248/45105)
CKafka 实例|QCE/CKAFKA|[指标详情](https://cloud.tencent.com/document/product/248/45121)
Memcached |QCE/MEMCACHED|指标详情说明文档(待上线)
Lighthouse |QCE/LIGHTHOUSE|[指标详情](https://cloud.tencent.com/document/product/248/60127)
分布式数据库 TDSQL MySQL 实例|QCE/TDMYSQL|[指标详情](https://cloud.tencent.com/document/product/248/54401)
轻量应用服务器Lighthouse |QCE/LIGHTHOUSE|[指标详情](https://cloud.tencent.com/document/product/248/60127)
分布式数据库 TDSQL MySQL|QCE/TDMYSQL|[指标详情](https://cloud.tencent.com/document/product/248/54401)
弹性公网 IP|QCE/LB|[指标详情](https://cloud.tencent.com/document/product/248/45099)
TDMQ RocketMQ 版|QCE/TDMQ|[指标详情](https://cloud.tencent.com/document/product/248/51450#tdmq-rocketmq-.E7.89.88)
消息队列RocketMQ版|QCE/TDMQ|[指标详情](https://cloud.tencent.com/document/product/248/51450#tdmq-rocketmq-.E7.89.88)
VPN 网关|QCE/VPNGW|[指标详情](https://cloud.tencent.com/document/product/248/45070)
VPN 通道|QCE/VPNX|[指标详情](https://cloud.tencent.com/document/product/248/45071)
CYNOSDB_MYSQL|QCE/CYNOSDB_MYSQL|[指标详情](https://cloud.tencent.com/document/product/248/45106)
云联网|QCE/VBC|[指标详情](https://cloud.tencent.com/document/product/248/75629)
数据传输 |QCE/DTS|指标详情说明文档(待上线)
数据传输 |QCE/DTS|[指标详情](https://cloud.tencent.com/document/product/248/82251)
专线网关 |QCE/DCG|指标详情说明文档(待上线)
全球应用加速|QCE/QAAP|[指标详情](https://cloud.tencent.com/document/product/248/45062)
WAF |QCE/WAF|指标详情说明文档(待上线)
CLB(内网)|QCE/LB_PRIVATE|[指标详情](https://cloud.tencent.com/document/product/248/51899)

Web应用防火墙 |QCE/WAF|[指标详情](https://cloud.tencent.com/document/product/248/48124)
负载均衡CLB(内网)|QCE/LB_PRIVATE|[指标详情](https://cloud.tencent.com/document/product/248/51899)
`后续会有更多的产品支持`

## 二、快速开始
Expand Down
8 changes: 8 additions & 0 deletions pkg/collector/handler_cbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ func (h *cbsHandler) GetNamespace() string {
}

func (h *cbsHandler) IsMetricVaild(m *metric.TcmMetric) bool {
// 暂时过滤nvme盘类指标
var dimensions []string
for _, v := range m.Meta.SupportDimensions {
dimensions = append(dimensions, v)
}
if util.IsStrInList(dimensions, "vmUuid") {
return false
}
return true
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/collector/handler_clb7.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ var (
"activeconnratio",
"newactiveconnratio",
"outtrafficratio",
"rsptimeout",
"setreqavg",
"setreqmax",
"setrspavg",
"setrspmax",
"settotalreq",
"vrsptimeout",
"vsettotalreq",
}
)

Expand Down
41 changes: 24 additions & 17 deletions pkg/collector/handler_clb_private.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ var (
}
)

var (
LbPrivateSupportDimensions = []string{"vip", "vpcId", "loadBalancerPort", "protocol", "lanIp", "port"}
)

func init() {
registerHandler(ClbPrivateNamespace, defaultHandlerEnabled, NewClbPrivateHandler)
}
Expand Down Expand Up @@ -119,32 +123,35 @@ func (h *ClbPrivateHandler) GetSeriesByAll(m *metric.TcmMetric) ([]*metric.TcmSe
return slist, nil
}

func (h *ClbPrivateHandler) GetSeriesByCustom(m *metric.TcmMetric) ([]*metric.TcmSeries, error) {
var slist []*metric.TcmSeries
func (h *ClbPrivateHandler) GetSeriesByCustom(m *metric.TcmMetric) (slist []*metric.TcmSeries, err error) {
for _, ql := range m.Conf.CustomQueryDimensions {
v, ok := ql[h.monitorQueryKey]
if !ok {
level.Error(h.logger).Log(
"msg", fmt.Sprintf("not found %s in queryDimensions", h.monitorQueryKey),
"ql", fmt.Sprintf("%v", ql))
continue
}
ins, err := h.collector.InstanceRepo.Get(v)
if err != nil {
level.Error(h.logger).Log("msg", "Instance not found", "err", err, "id", v)
if !h.checkMonitorQueryKeys(m, ql) {
continue
}

sl, err := h.getSeriesByMetricType(m, ins)
s, err := metric.NewTcmSeries(m, ql, nil)
if err != nil {
level.Error(h.logger).Log("msg", "Create metric series fail",
"metric", m.Meta.MetricName, "instacne", ins.GetInstanceId())
level.Error(h.logger).Log("msg", "Create metric series fail", "metric", m.Meta.MetricName,
"ql", fmt.Sprintf("%v", ql))
continue
}
slist = append(slist, sl...)
slist = append(slist, s)
}
return slist, nil
return
}
func (h *ClbPrivateHandler) checkMonitorQueryKeys(m *metric.TcmMetric, ql map[string]string) bool {
for k := range ql {
if !util.IsStrInList(LbPrivateSupportDimensions, k) {
level.Error(h.logger).Log("msg", fmt.Sprintf("not found %s in supportQueryDimensions", k),
"ql", fmt.Sprintf("%v", ql),
"sd", fmt.Sprintf("%v", m.Meta.SupportDimensions),
)
return false
}
}
return true
}

func (h *ClbPrivateHandler) getSeriesByMetricType(m *metric.TcmMetric, ins instance.TcInstance) ([]*metric.TcmSeries, error) {
var dimensions []string
for _, v := range m.Meta.SupportDimensions {
Expand Down
18 changes: 18 additions & 0 deletions pkg/collector/handler_tdmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package collector

import (
"fmt"
"strings"
"time"

"github.com/go-kit/log"
Expand All @@ -17,6 +18,19 @@ const (
TdmqInstanceidKey = "tenant"
)

var (
RocketMQOnlyIncludeMetrics = []string{
"ropratein",
"roprateout",
"ropthroughputin",
"ropthroughputout",
"ropmsgbacklog",
"ropmsgaveragesize",
"ropinmessagetotal",
"ropgroupcount",
}
)

func init() {
registerHandler(TdmqNamespace, defaultHandlerEnabled, NewTdmqHandler)
}
Expand All @@ -36,6 +50,10 @@ func (h *tdmqHandler) GetNamespace() string {
}

func (h *tdmqHandler) IsMetricVaild(m *metric.TcmMetric) bool {
// 暂时只支持 TDMQ RocketMQ 版指标
if !util.IsStrInList(RocketMQOnlyIncludeMetrics, strings.ToLower(m.Meta.MetricName)) {
return false
}
_, ok := excludeMetricName[m.Meta.MetricName]
if ok {
return false
Expand Down

0 comments on commit cf5201f

Please sign in to comment.