From afa39bf0db90224e662f6fd3ee3590ba63fa8730 Mon Sep 17 00:00:00 2001 From: chen Date: Thu, 11 Jul 2024 22:36:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=832.0.10=E7=89=88=E6=9C=AC=20(#?= =?UTF-8?q?66)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.清理已有模板中的copyright链接 2.新增gaussdb for mysql服务grafana模 3.适配geminidb redis单维度指标 4.logs.yml文件路径支持可配置 5.补充NAT服务下的指标 --- README.md | 8 +- README_cn.md | 10 +- clouds.yml | 1 + collector/apic.go | 2 +- collector/apig.go | 2 +- collector/cbr.go | 2 +- collector/cc.go | 4 +- collector/cdm.go | 2 +- collector/cfw_test.go | 10 +- collector/collector.go | 6 +- collector/collector_test.go | 9 +- collector/config.go | 61 +- collector/config_test.go | 2 +- collector/ddms.go | 2 +- collector/dds.go | 2 +- collector/dli_test.go | 8 +- collector/dws.go | 2 +- collector/ecs.go | 2 +- collector/elb.go | 2 +- collector/eps.go | 13 +- collector/evs.go | 2 +- collector/gaussdbv5.go | 2 +- collector/lakeformation.go | 2 +- collector/metrics.go | 4 +- collector/mrs.go | 2 +- collector/nosql.go | 45 +- collector/nosql_test.go | 36 +- collector/rds.go | 2 + collector/rms.go | 8 +- collector/rms_test.go | 30 +- collector/utils.go | 4 +- collector/version.go | 2 +- collector/waf.go | 2 +- collector/waf_test.go | 12 +- .../templates/css(es)_dashboard_template.json | 10 - .../templates/dcaas_dashboard_template.json | 10 - .../templates/dcs_dashboard_template.json | 10 - .../templates/dds_dashboard_template.json | 10 - .../dms(Kafka)_dashboard_template.json | 10 - .../templates/elb_dashboard_template.json | 10 - .../gaussdb(mysql)_dashboard_template.json | 1879 +++++++++++++++++ .../templates/rds_dashboard_template.json | 10 - .../templates/vpc_dashboard_template.json | 10 - grafana_dashboard/use_grafana_template.md | 1 + logs/logs.go | 4 +- logs/logs_test.go | 44 + main.go | 45 +- metric.yml | 476 ++--- 48 files changed, 2374 insertions(+), 458 deletions(-) create mode 100644 grafana_dashboard/templates/gaussdb(mysql)_dashboard_template.json create mode 100644 logs/logs_test.go diff --git a/README.md b/README.md index b4961bc1..7df08c5a 100644 --- a/README.md +++ b/README.md @@ -61,15 +61,19 @@ The "URL" value can be get from [Identity and Access Management (IAM) endpoint l ``` global: prefix: "huaweicloud" - port: ":8087" + port: "{private IP}:8087" # For security purposes, you are advised not to expose the Expoter service port to the public network. You are advised to set this parameter to 127.0.0.1:{port} or {private IP address}:{port}, for example, 192.168.1.100:8087. If the port needs to be exposed to the public network, ensure that the security group, firewall, and iptables access control policies are properly configured to meet the minimum access permission principle. metric_path: "/metrics" scrape_batch_size: 300 resource_sync_interval_minutes: 20 # Update frequency of resource information: resource information is updated every 180 minutes by default; If this parameter is set to a value less than 10 minutes, the information is updated every 10 minutes. ep_ids: "xxx1,xxx2" # This is optional. Filter resources by enterpries project, cloudeye-exporter will get all resources when this is empty, if you need multiple enterprise project, use comma split them. + logs_conf_path: "/root/logs.yml" # This is optional. We recommend that you use an absolute path for the log configuration file path. If this line is absent, the program will use configuration file in the directory where the startup command is executed by default. + metrics_conf_path: "/root/metrics.yml" # This is optional. We recommend that you use an absolute path for the metrics configuration file path. If this line is absent, the program will use configuration file in the directory where the startup command is executed by default. + endpoints_conf_path: "/root/endpoints.yml" # This is optional. We recommend that you use an absolute path for the service endpoints configuration file path. If this line is absent, the program will use configuration file in the directory where the startup command is executed by default. + ignore_ssl_verify: false # This is optional. The SSL certificate is verified by default when the exporter queries resources or indicators. If the exporter is abnormal due to SSL certificate verification, you can set this configuration to true to skip SSL certificate verification. auth: auth_url: "https://iam.{region_id}.myhuaweicloud.com/v3" project_name: "{project_name}" - access_key: "{access_key}" + access_key: "{access_key}" # It is strongly remommended that you use a script to decrypt the AK/SK by following the instructions provided in section 4.1 to prevent information leakage caused by plaintext AK/SK configuration in the configuration file. secret_key: "{secret_key}" region: "{region}" ``` diff --git a/README_cn.md b/README_cn.md index 95ce149a..dea84a13 100644 --- a/README_cn.md +++ b/README_cn.md @@ -81,14 +81,18 @@ tar -xzvf cloudeye-exporter.v2.0.5.tar.gz * [地区和终端节点(国际站)](https://developer.huaweicloud.com/intl/en-us/endpoint?IAM) ``` global: - port: ":8087" # 监听端口 :8087代表在全部网络接口上开启监听8087端口,限定内部访问也可以指定IP例如:192.168.1.100:8087 + port: "{private IP}:8087" # 监听端口 :出于安全考虑,建议不将expoter服务端口暴露到公网,建议配置为127.0.0.1:{port},或{内网ip}:{port},例如:192.168.1.100:8087;如业务需要将该端口暴露到公网,请确保合理配置安全组,防火墙,iptables等访问控制策略,确保最小访问权限 scrape_batch_size: 300 resource_sync_interval_minutes: 20 # 资源信息更新频率:默认180分钟更新一次;该配置值小于10分钟,将以10分钟1次为资源信息更新频率 ep_ids: "xxx1,xxx2" # 可选配置,根据企业项目ID过滤资源,不配置默认查询所有资源的指标,多个ID使用英文逗号进行分割。 + logs_conf_path: "/root/logs.yml" # 可选配置,指定日志打印配置文件路径,建议使用绝对路径。若未指定,程序将默认使用执行启动命令所在目录下的日志配置文件。 + metrics_conf_path: "/root/metric.yml" # 可选配置,指定指标配置文件路径,建议使用绝对路径。若未指定,程序将默认使用执行启动命令所在目录下的指标配置文件。 + endpoints_conf_path: "/root/endpoints.yml" # 可选配置,指定服务域名配置文件路径,建议使用绝对路径。若未指定,程序将默认使用执行启动命令所在目录下的服务域名配置文件。 + ignore_ssl_verify: false # 可选配置,exporter查询资源/指标时默认校验ssl证书;若用户因ssl证书校验导致功能异常,可将该配置项配置为true跳过ssl证书校验 auth: auth_url: "https://iam.{region_id}.myhuaweicloud.com/v3" project_name: "cn-north-1" # 华为云项目名称,可以在“华为云->统一身份认证服务->项目”中查看 - access_key: "" # IAM用户访问密钥 您可参考3.1章节使用命令行输入加密后的ak sk,避免在配置文件中明文配置AK SK + access_key: "" # IAM用户访问密钥 您可参考4.1章节,使用脚本将ak sk解密后传入,避免因在配置文件中明文配置AK SK而引发信息泄露 secret_key: "" region: "cn-north-1" # 区域ID ``` @@ -110,7 +114,7 @@ auth: ./cloudeye-exporter -config=clouds.yml ``` -3.1 出于安全考虑cloudeye-exporter提供了 -s参数, 可以通过命令行交互的方式输入ak sk避免明文配置在clouds.yml文件中引起泄露 +4.1 出于安全考虑cloudeye-exporter提供了 -s参数, 可以通过命令行交互的方式输入ak sk避免明文配置在clouds.yml文件中引起泄露 ```shell ./cloudeye-exporter -s true ``` diff --git a/clouds.yml b/clouds.yml index c8230020..af06d24f 100644 --- a/clouds.yml +++ b/clouds.yml @@ -2,6 +2,7 @@ global: prefix: "huaweicloud" scrape_batch_size: 300 resource_sync_interval_minutes: 180 + ignore_ssl_verify: false auth: auth_url: "https://iam.xxx.yyy.com/v3" project_name: "{project_name}" diff --git a/collector/apic.go b/collector/apic.go index f9404e18..a62e756c 100644 --- a/collector/apic.go +++ b/collector/apic.go @@ -174,6 +174,6 @@ func showDetailsOfInstanceV2(instanceID string) (*model.ShowDetailsOfInstanceV2R func getAPICSClient() *apig.ApigClient { return apig.NewApigClient(apig.ApigClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("apig", "v2")).Build()) } diff --git a/collector/apig.go b/collector/apig.go index f7c6951d..6939d9fd 100644 --- a/collector/apig.go +++ b/collector/apig.go @@ -122,6 +122,6 @@ func getAllAPIGAppsInstances() ([]APIGAppsInfo, error) { func getAPIGSClient() *apig.ApigClient { return apig.NewApigClient(apig.ApigClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("apig", "v1.0")).Build()) } diff --git a/collector/cbr.go b/collector/cbr.go index a910776a..50f966e6 100644 --- a/collector/cbr.go +++ b/collector/cbr.go @@ -89,6 +89,6 @@ func getAllCbrInstancesFromCBR() ([]ResourceBaseInfo, error) { func getCBRClient() *cbr.CbrClient { return cbr.NewCbrClient(cbr.CbrClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("cbr", "v3")).Build()) } diff --git a/collector/cc.go b/collector/cc.go index a2ea0789..ddef3c5f 100644 --- a/collector/cc.go +++ b/collector/cc.go @@ -6,6 +6,7 @@ import ( http_client "github.com/huaweicloud/huaweicloud-sdk-go-v3/core" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global" + "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/config" cc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cc/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cc/v3/model" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cc/v3/region" @@ -162,7 +163,8 @@ func getCCClient() *cc.CcClient { } func getCCClientBuilder() *http_client.HcHttpClientBuilder { - builder := cc.CcClientBuilder().WithCredential(global.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).Build()) + builder := cc.CcClientBuilder().WithCredential(global.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).Build()). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)) if endpoint, ok := endpointConfig["cc"]; ok { builder.WithEndpoint(endpoint) } else { diff --git a/collector/cdm.go b/collector/cdm.go index 4d20b142..848d9e27 100644 --- a/collector/cdm.go +++ b/collector/cdm.go @@ -49,7 +49,7 @@ func (getter CDMInfo) GetResourceInfo() (map[string]labelInfo, []cesmodel.Metric func getCDMClient() *cdm.CdmClient { return cdm.NewCdmClient(cdm.CdmClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("cdm", "v1.1")).Build()) } diff --git a/collector/cfw_test.go b/collector/cfw_test.go index adcc24e1..ad44de16 100644 --- a/collector/cfw_test.go +++ b/collector/cfw_test.go @@ -15,7 +15,7 @@ import ( func TestCFWInfo_GetResourceInfo_configIsNil(t *testing.T) { patches := getPatches() defer patches.Reset() - logs.InitLog() + logs.InitLog("") cfwInfoTest := CFWInfo{} labelInfos, filterMetrics := cfwInfoTest.GetResourceInfo() assert.Nil(t, labelInfos) @@ -28,7 +28,7 @@ func TestCFWInfo_GetResourceInfo_dimConfigIsNotExists(t *testing.T) { defer patches.Reset() patches.ApplyFuncReturn(getMetricConfigMap, metricConfigMap) - logs.InitLog() + logs.InitLog("") cfwInfoTest := CFWInfo{} labelInfos, filterMetrics := cfwInfoTest.GetResourceInfo() assert.Nil(t, labelInfos) @@ -43,7 +43,7 @@ func TestCFWInfo_GetResourceInfo_dimConfigIsEmpty(t *testing.T) { "fw_instance_id": nil, } patches.ApplyFuncReturn(getMetricConfigMap, metricConfigMap) - logs.InitLog() + logs.InitLog("") cfwInfoTest := CFWInfo{} labelInfos, filterMetrics := cfwInfoTest.GetResourceInfo() assert.Nil(t, labelInfos) @@ -60,7 +60,7 @@ func TestCFWInfo_GetResourceInfo_getResourcesFromRMSFailed(t *testing.T) { patches.ApplyFuncReturn(getMetricConfigMap, metricConfigMap) patches.ApplyFuncReturn(listResources, nil, errors.New("test err")) - logs.InitLog() + logs.InitLog("") cfwInfoTest := CFWInfo{} labelInfos, filterMetrics := cfwInfoTest.GetResourceInfo() assert.Nil(t, labelInfos) @@ -76,7 +76,7 @@ func TestCFWInfo_GetResourceInfo_success(t *testing.T) { } patches.ApplyFuncReturn(getMetricConfigMap, metricConfigMap) patches.ApplyFuncReturn(listResources, resourceEntityInit(), nil) - logs.InitLog() + logs.InitLog("") cfwInfoTest := CFWInfo{} // 两个指标,两个资源 labelInfos, filterMetrics := cfwInfoTest.GetResourceInfo() diff --git a/collector/collector.go b/collector/collector.go index 33205da8..dd08ad4c 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -59,9 +59,13 @@ func (exporter *BaseHuaweiCloudExporter) listMetrics(namespace string) ([]model. allResourcesInfo, metrics := exporter.listAllResources(namespace) logs.Logger.Debugf("[%s] Resource number of %s: %d", exporter.txnKey, namespace, len(allResourcesInfo)) - if len(metrics) > 0 && CloudConf.Global.EpIds != "" { + if len(metrics) > 0 { return metrics, allResourcesInfo } + // 用户指定了EPID但是metrics为空的场景下,则不应返回数据 + if CloudConf.Global.EpIds != "" { + return nil, nil + } logs.Logger.Debugf("[%s] Start to getAllMetric from CES", exporter.txnKey) allMetrics, err := listAllMetrics(namespace) if err != nil { diff --git a/collector/collector_test.go b/collector/collector_test.go index 0ada7b62..3c3a8957 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -1,15 +1,16 @@ package collector import ( - "github.com/agiledragon/gomonkey/v2" - "github.com/huaweicloud/cloudeye-exporter/logs" - "go.uber.org/zap/zapcore" "sync" "testing" "time" + "github.com/agiledragon/gomonkey/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ces/v1/model" "github.com/stretchr/testify/assert" + "go.uber.org/zap/zapcore" + + "github.com/huaweicloud/cloudeye-exporter/logs" ) func TestReplaceName(t *testing.T) { @@ -146,7 +147,7 @@ func TestSetProData1(t *testing.T) { return nil }) defer patches.Reset() - logs.InitLog() + logs.InitLog("") exporter.Collect(nil) exporter.setProData(nil, nil, metricDataArray, resourceInfo, &proMap) assert.Equal(t, 3, len(label.Name)) diff --git a/collector/config.go b/collector/config.go index 24652456..46956946 100644 --- a/collector/config.go +++ b/collector/config.go @@ -2,6 +2,7 @@ package collector import ( "errors" + "fmt" "io/ioutil" "net/http" "path/filepath" @@ -21,12 +22,11 @@ type CloudAuth struct { ProjectName string `yaml:"project_name"` ProjectID string `yaml:"project_id"` DomainName string `yaml:"domain_name"` - AccessKey string `yaml:"access_key"` - Region string `yaml:"region"` - SecretKey string `yaml:"secret_key"` - AuthURL string `yaml:"auth_url"` - UserName string `yaml:"user_name"` - Password string `yaml:"password"` + // 建议您优先使用ReadMe文档中 4.1章节的方式,使用脚本将AccessKey,SecretKey解密后传入,避免在配置文件中明文配置AK SK导致信息泄露 + AccessKey string `yaml:"access_key"` + Region string `yaml:"region"` + SecretKey string `yaml:"secret_key"` + AuthURL string `yaml:"auth_url"` } type Global struct { @@ -38,6 +38,10 @@ type Global struct { ScrapeBatchSize int `yaml:"scrape_batch_size"` ResourceSyncIntervalMinutes int `yaml:"resource_sync_interval_minutes"` EpIds string `yaml:"ep_ids"` + MetricsConfPath string `yaml:"metrics_conf_path"` + LogsConfPath string `yaml:"logs_conf_path"` + EndpointsConfPath string `yaml:"endpoints_conf_path"` + IgnoreSSLVerify bool `yaml:"ignore_ssl_verify"` } type CloudConfig struct { @@ -72,8 +76,6 @@ func InitCloudConf(file string) error { if err != nil { return err } - - initEndpointConfig() return err } @@ -118,6 +120,18 @@ func SetDefaultConfigValues(config *CloudConfig) { if config.Global.ResourceSyncIntervalMinutes <= 0 { config.Global.ResourceSyncIntervalMinutes = 180 } + + if config.Global.MetricsConfPath == "" { + config.Global.MetricsConfPath = "./metric.yml" + } + + if config.Global.LogsConfPath == "" { + config.Global.LogsConfPath = "./logs.yml" + } + + if config.Global.EndpointsConfPath == "" { + config.Global.EndpointsConfPath = "./endpoints.yml" + } } type MetricConf struct { @@ -129,7 +143,7 @@ var metricConf map[string]MetricConf func InitMetricConf() error { metricConf = make(map[string]MetricConf) - data, err := ioutil.ReadFile("metric.yml") + data, err := ioutil.ReadFile(CloudConf.Global.MetricsConfPath) if err != nil { return err } @@ -158,12 +172,9 @@ type Config struct { DomainName string EndpointType string IdentityEndpoint string - Password string Region string ProjectID string ProjectName string - Token string - Username string UserID string } @@ -174,9 +185,8 @@ func InitConfig() error { conf.ProjectName = CloudConf.Auth.ProjectName conf.ProjectID = CloudConf.Auth.ProjectID conf.DomainName = CloudConf.Auth.DomainName - conf.Username = CloudConf.Auth.UserName conf.Region = CloudConf.Auth.Region - conf.Password = CloudConf.Auth.Password + // 安全模式下,ak/sk通过用户交互获取,避免明文方式存在于存储介质中 if SecurityMod { conf.AccessKey = TmpAK conf.SecretKey = TmpSK @@ -186,12 +196,12 @@ func InitConfig() error { } if conf.ProjectID == "" && conf.ProjectName == "" { - logs.Logger.Error("Init config error: ProjectID or ProjectName must setting.") + fmt.Printf("Init config error: ProjectID or ProjectName must setting.") return errors.New("init config error: ProjectID or ProjectName must setting") } req, err := http.NewRequest("GET", conf.IdentityEndpoint, nil) if err != nil { - logs.Logger.Error("Auth url is invalid.") + fmt.Printf("Auth url is invalid.") return err } host = req.Host @@ -199,11 +209,11 @@ func InitConfig() error { if conf.ProjectID == "" { resp, err := getProjectInfo() if err != nil { - logs.Logger.Errorf("Get project info error: %s", err.Error()) + fmt.Printf("Get project info error: %s", err.Error()) return err } if len(*resp.Projects) == 0 { - logs.Logger.Error("project info is empty") + fmt.Printf("Project info is empty") return errors.New("project info is empty") } @@ -223,18 +233,23 @@ func getProjectInfo() (*model.KeystoneListProjectsResponse, error) { WithAk(conf.AccessKey). WithSk(conf.SecretKey). Build()). - WithHttpConfig(config.DefaultHttpConfig(). - WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). Build()) return iamclient.KeystoneListProjects(&model.KeystoneListProjectsRequest{Name: &conf.ProjectName}) } var endpointConfig map[string]string -func initEndpointConfig() { - context, err := ioutil.ReadFile("endpoints.yml") +func InitEndpointConfig(path string) { + realPath, err := NormalizePath(path) if err != nil { - logs.Logger.Errorf("Init endpoint config error: %s", err.Error()) + logs.Logger.Errorf("Normalize endpoint config err: %s", err.Error()) + return + } + + context, err := ioutil.ReadFile(realPath) + if err != nil { + logs.Logger.Infof("Invalid endpoint config path, default config will be used instead") return } err = yaml.Unmarshal(context, &endpointConfig) diff --git a/collector/config_test.go b/collector/config_test.go index e0184d5c..c6b0896c 100644 --- a/collector/config_test.go +++ b/collector/config_test.go @@ -109,7 +109,7 @@ func TestInitEndpointConfig(t *testing.T) { patches := testCase.patches() patches.ApplyMethod(&logs.Logger, "Errorf", func(logger *logs.LoggerConstructor, template string, args ...interface{}) {}) defer patches.Reset() - initEndpointConfig() + InitEndpointConfig("") testCase.expect(t) }) } diff --git a/collector/ddms.go b/collector/ddms.go index ece99cbd..afa1ebc5 100644 --- a/collector/ddms.go +++ b/collector/ddms.go @@ -114,6 +114,6 @@ func getDdmsInstanceNodes(instanceId string) ([]ddmmodel.ShowNodeResponse, error func getDDMSClient() *ddm.DdmClient { return ddm.NewDdmClient(ddm.DdmClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("ddm", "v1")).Build()) } diff --git a/collector/dds.go b/collector/dds.go index 505cbd76..5c6f3422 100644 --- a/collector/dds.go +++ b/collector/dds.go @@ -125,6 +125,6 @@ func fmtDdsInstance(instance ddsmodel.QueryInstanceResponse) DdsInstanceInfo { func getDDSClient() *dds.DdsClient { return dds.NewDdsClient(dds.DdsClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("dds", "v3")).Build()) } diff --git a/collector/dli_test.go b/collector/dli_test.go index d051567f..e3a6991d 100644 --- a/collector/dli_test.go +++ b/collector/dli_test.go @@ -15,7 +15,7 @@ import ( func TestBuildElasticPoolWhenMapIsEmpty(t *testing.T) { patches := getPatches() defer patches.Reset() - logs.InitLog() + logs.InitLog("") resourceInfos := map[string]labelInfo{} filterMetrics := make([]model.MetricInfoList, 0) sysConfigMap := getMetricConfigMap("SYS.DLI") @@ -26,7 +26,7 @@ func TestBuildElasticPoolWhenMapIsEmpty(t *testing.T) { func TestBuildElasticPoolWhenGetError(t *testing.T) { patches := getPatches() defer patches.Reset() - logs.InitLog() + logs.InitLog("") resourceInfos := map[string]labelInfo{} filterMetrics := make([]model.MetricInfoList, 0) sysConfigMap := map[string][]string{} @@ -41,7 +41,7 @@ func TestBuildElasticPoolWhenGetError(t *testing.T) { func TestBuildElasticPool(t *testing.T) { patches := getPatches() defer patches.Reset() - logs.InitLog() + logs.InitLog("") resourceInfos := map[string]labelInfo{} filterMetrics := make([]model.MetricInfoList, 0) sysConfigMap := map[string][]string{} @@ -77,7 +77,7 @@ func TestBuildElasticPool(t *testing.T) { func TestGetQueuesFromRMS(t *testing.T) { patches := getPatches() defer patches.Reset() - logs.InitLog() + logs.InitLog("") id1 := "123123123" name1 := "test_name" response := []rmsModel.ResourceEntity{ diff --git a/collector/dws.go b/collector/dws.go index ffb502c0..e51b1b25 100644 --- a/collector/dws.go +++ b/collector/dws.go @@ -54,6 +54,6 @@ func (getter DWSInfo) GetResourceInfo() (map[string]labelInfo, []model.MetricInf func getDWSClient() *dws.DwsClient { return dws.NewDwsClient(dws.DwsClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("dws", "v1.0")).Build()) } diff --git a/collector/ecs.go b/collector/ecs.go index e4eb11c1..87b78d88 100644 --- a/collector/ecs.go +++ b/collector/ecs.go @@ -70,7 +70,7 @@ type EcsInstancesInfo struct { func getECSClient() *ecs.EcsClient { return ecs.NewEcsClient(ecs.EcsClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("ecs", "v2")).Build()) } func getAllServer() ([]EcsInstancesInfo, error) { diff --git a/collector/elb.go b/collector/elb.go index e87e9092..73cd7ed9 100644 --- a/collector/elb.go +++ b/collector/elb.go @@ -21,7 +21,7 @@ var poolsMap map[string]model.Pool func getELBClient() *elb.ElbClient { return elb.NewElbClient(elb.ElbClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("elb", "v2")).Build()) } diff --git a/collector/eps.go b/collector/eps.go index 2bd67efa..bbcb5380 100644 --- a/collector/eps.go +++ b/collector/eps.go @@ -6,9 +6,12 @@ import ( http_client "github.com/huaweicloud/huaweicloud-sdk-go-v3/core" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global" + "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/config" eps "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eps/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eps/v1/model" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eps/v1/region" + + "github.com/huaweicloud/cloudeye-exporter/logs" ) var epsInfo = &EpsInfo{ @@ -29,7 +32,10 @@ func getEPSClient() *eps.EpsClient { } func getEPSClientBuilder() *http_client.HcHttpClientBuilder { - builder := eps.EpsClientBuilder().WithCredential(global.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithDomainId(conf.DomainID).Build()) + builder := eps.EpsClientBuilder().WithCredential(global.NewCredentialsBuilder(). + WithAk(conf.AccessKey).WithSk(conf.SecretKey). + WithDomainId(conf.DomainID).Build()). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)) if endpoint, ok := endpointConfig["eps"]; ok { builder.WithEndpoint(endpoint) } else { @@ -64,7 +70,6 @@ func listEps() ([]model.EpDetail, error) { client := getEPSClient() var resources []model.EpDetail - for { response, err := client.ListEnterpriseProject(req) if err != nil { @@ -74,6 +79,10 @@ func listEps() ([]model.EpDetail, error) { if len(*response.EnterpriseProjects) == 0 { break } + if len(resources) > MaxEpsCount { + logs.Logger.Errorf("eps not allowed to exceed 10000") + break + } *req.Offset += limit } epsInfo.EpDetails = resources diff --git a/collector/evs.go b/collector/evs.go index 12572eef..e0c5701b 100644 --- a/collector/evs.go +++ b/collector/evs.go @@ -86,7 +86,7 @@ func (getter EVSInfo) GetResourceInfo() (map[string]labelInfo, []model.MetricInf func getEVSClient() *evs.EvsClient { return evs.NewEvsClient(evs.EvsClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("evs", "v2")).Build()) } diff --git a/collector/gaussdbv5.go b/collector/gaussdbv5.go index 82f58b1e..b4f14305 100644 --- a/collector/gaussdbv5.go +++ b/collector/gaussdbv5.go @@ -76,7 +76,7 @@ func (getter GAUSSDBV5Info) GetResourceInfo() (map[string]labelInfo, []cesmodel. func getGaussdbforopengaussClient() *gaussdbforopengauss.GaussDBforopenGaussClient { return gaussdbforopengauss.NewGaussDBforopenGaussClient(gaussdbforopengauss.GaussDBforopenGaussClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("gaussdb-opengauss", "v3")).Build()) } diff --git a/collector/lakeformation.go b/collector/lakeformation.go index 0b8c0652..1798c2d5 100644 --- a/collector/lakeformation.go +++ b/collector/lakeformation.go @@ -60,7 +60,7 @@ func (getter LakeFormationInfo) GetResourceInfo() (map[string]labelInfo, []model func getLakeFormationClient() *lakeformation.LakeFormationClient { return lakeformation.NewLakeFormationClient(lakeformation.LakeFormationClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("lakeformation", "v1")).Build()) } diff --git a/collector/metrics.go b/collector/metrics.go index beaf6690..6c8fda22 100644 --- a/collector/metrics.go +++ b/collector/metrics.go @@ -21,7 +21,7 @@ var ( func getCESClient() *ces.CesClient { return ces.NewCesClient(ces.CesClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("ces", "v1")).Build()) } @@ -72,7 +72,7 @@ func listAllMetrics(namespace string) ([]model.MetricInfoList, error) { func getCESClientV2() *cesv2.CesClient { return cesv2.NewCesClient(ces.CesClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("ces", "v2")).Build()) } diff --git a/collector/mrs.go b/collector/mrs.go index 187dbf00..b3a5c261 100644 --- a/collector/mrs.go +++ b/collector/mrs.go @@ -78,7 +78,7 @@ func getMRSClusterFromRMS() ([]ResourceBaseInfo, error) { func getMRSClient() *mrs.MrsClient { return mrs.NewMrsClient(mrs.MrsClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("mrs", "v1.1")).Build()) } diff --git a/collector/nosql.go b/collector/nosql.go index 7c57288b..7684808f 100644 --- a/collector/nosql.go +++ b/collector/nosql.go @@ -15,11 +15,11 @@ import ( var ( nosqlInfo serversInfo - dimMap = map[string]string{ - "cassandra": "cassandra_cluster_id,cassandra_node_id", - "mongodb": "mongodb_cluster_id,mongodb_node_id", - "influxdb": "influxdb_cluster_id,influxdb_node_id", - "redis": "redis_cluster_id,redis_node_id", + dimMap = map[string][]string{ + "cassandra": {"cassandra_cluster_id,cassandra_node_id"}, + "mongodb": {"mongodb_cluster_id", "mongodb_cluster_id,mongodb_node_id"}, + "influxdb": {"influxdb_cluster_id,influxdb_node_id"}, + "redis": {"redis_cluster_id", "redis_cluster_id,redis_node_id"}, } ) @@ -47,17 +47,28 @@ func (getter NoSQLInfo) GetResourceInfo() (map[string]labelInfo, []model.MetricI } func buildMetricsAndInfo(instance nosqlmodel.ListInstancesResult, filterMetrics *[]model.MetricInfoList, resourceInfos map[string]labelInfo) { - dimStr, ok := dimMap[instance.Datastore.Type] + dimStrArr, ok := dimMap[instance.Datastore.Type] if !ok { logs.Logger.Debugf("Instances type is invalid") return } - metricNames := getMetricConfigMap("SYS.NoSQL")[dimStr] - if len(metricNames) == 0 { - logs.Logger.Debugf("metric names is empty: %s", dimStr) - return + var metricNames []string + for _, dimStr := range dimStrArr { + metricNames = getMetricConfigMap("SYS.NoSQL")[dimStr] + if len(metricNames) == 0 { + logs.Logger.Debugf("metric names is empty: %s", dimStr) + continue + } + dimName := strings.Split(dimStr, ",") + if len(dimName) == 1 { + buildClusterResources(instance, dimName, metricNames, filterMetrics, resourceInfos) + } else { + buildNodeDimResources(instance, dimName, metricNames, filterMetrics, resourceInfos) + } } - dimName := strings.Split(dimStr, ",") +} + +func buildNodeDimResources(instance nosqlmodel.ListInstancesResult, dimName []string, metricNames []string, filterMetrics *[]model.MetricInfoList, resourceInfos map[string]labelInfo) { for _, group := range instance.Groups { for _, node := range group.Nodes { metrics := buildDimensionMetrics(metricNames, "SYS.NoSQL", @@ -73,6 +84,16 @@ func buildMetricsAndInfo(instance nosqlmodel.ListInstancesResult, filterMetrics } } +func buildClusterResources(instance nosqlmodel.ListInstancesResult, dimName []string, metricNames []string, filterMetrics *[]model.MetricInfoList, resourceInfos map[string]labelInfo) { + metrics := buildSingleDimensionMetrics(metricNames, "SYS.NoSQL", dimName[0], instance.Id) + *filterMetrics = append(*filterMetrics, metrics...) + instanceInfo := labelInfo{ + Name: []string{"instanceName", "lbIPAddress", "lbPort", "epId", "type"}, + Value: []string{instance.Name, getDefaultString(instance.LbIpAddress), getDefaultString(instance.LbPort), instance.EnterpriseProjectId, instance.Datastore.Type}, + } + resourceInfos[GetResourceKeyFromMetricInfo(metrics[0])] = instanceInfo +} + func getAllNoSQLInstances() ([]nosqlmodel.ListInstancesResult, error) { limit := int32(100) offset := int32(0) @@ -97,6 +118,6 @@ func getAllNoSQLInstances() ([]nosqlmodel.ListInstancesResult, error) { func getNoSQLClient() *nosql.GaussDBforNoSQLClient { return nosql.NewGaussDBforNoSQLClient(nosql.GaussDBforNoSQLClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("gaussdb-nosql", "v3")).Build()) } diff --git a/collector/nosql_test.go b/collector/nosql_test.go index afe1e175..951a651e 100644 --- a/collector/nosql_test.go +++ b/collector/nosql_test.go @@ -3,14 +3,46 @@ package collector import ( "testing" - "github.com/agiledragon/gomonkey/v2" nosqlmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdbfornosql/v3/model" "github.com/stretchr/testify/assert" + + "github.com/huaweicloud/cloudeye-exporter/logs" ) func TestNoSQLInfo_GetResourceInfo(t *testing.T) { - patches := gomonkey.ApplyFuncReturn(getAllNoSQLInstances, []nosqlmodel.ListInstancesResult{}, nil) + instance := []nosqlmodel.ListInstancesResult{ + { + Id: "1111", + Name: "test_xxx", + Datastore: &nosqlmodel.ListInstancesDatastoreResult{ + Type: "redis", + }, + Groups: []nosqlmodel.ListInstancesGroupResult{ + { + Nodes: []nosqlmodel.ListInstancesNodeResult{ + { + Id: "test_node111", + Name: "test_node1", + }, + { + Id: "test_node222", + Name: "test_node2", + }, + }, + }, + }, + }, + } + sysConfig := map[string][]string{ + "redis_cluster_id": {"redis667_cluster_qps"}, + "redis_cluster_id,redis_node_id": {"gemini001_cpu_usage"}, + "mongodb_cluster_id": {"mongodb001_command_ps"}, + } + patches := getPatches() + patches = patches.ApplyFuncReturn(getAllNoSQLInstances, instance, nil) + patches = patches.ApplyFuncReturn(getMetricConfigMap, sysConfig) defer patches.Reset() + logs.InitLog("") noSQLInfo1 := NoSQLInfo{} _, filteredMetricInfos := noSQLInfo1.GetResourceInfo() assert.NotNil(t, filteredMetricInfos) diff --git a/collector/rds.go b/collector/rds.go index 67146c8b..26ec9b55 100644 --- a/collector/rds.go +++ b/collector/rds.go @@ -44,6 +44,8 @@ func (getter RDSInfo) GetResourceInfo() (map[string]labelInfo, []model.MetricInf dimName = "postgresql_cluster_id" case "sqlserver": dimName = "rds_cluster_sqlserver_id" + default: + logs.Logger.Error("Failed to match case") } if metricNames, ok := sysConfigMap[dimName]; ok { metrics := buildSingleDimensionMetrics(metricNames, "SYS.RDS", dimName, instance.ID) diff --git a/collector/rms.go b/collector/rms.go index 8b2913e9..57dfab84 100644 --- a/collector/rms.go +++ b/collector/rms.go @@ -6,6 +6,7 @@ import ( http_client "github.com/huaweicloud/huaweicloud-sdk-go-v3/core" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global" + "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/config" v1 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rms/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rms/v1/model" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rms/v1/region" @@ -18,7 +19,7 @@ func getRMSClient() *v1.RmsClient { } func getRMSClientBuilder() *http_client.HcHttpClientBuilder { - builder := v1.RmsClientBuilder().WithCredential(global.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithDomainId(conf.DomainID).Build()) + builder := v1.RmsClientBuilder().WithCredential(global.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithDomainId(conf.DomainID).Build()).WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)) if endpoint, ok := endpointConfig["rms"]; ok { builder.WithEndpoint(endpoint) } else { @@ -66,5 +67,10 @@ func getResourcesFromRMS(req *model.ListResourcesRequest) ([]model.ResourceEntit } req.Marker = response.PageInfo.NextMarker } + + if len(resources) == 0 { + logs.Logger.Infof("Get empty resource list from rms") + } + return resources, nil } diff --git a/collector/rms_test.go b/collector/rms_test.go index 545d9264..40e16609 100644 --- a/collector/rms_test.go +++ b/collector/rms_test.go @@ -20,7 +20,7 @@ func TestGetRmsClient(t *testing.T) { func TestListResources(t *testing.T) { patches := getPatches() defer patches.Reset() - logs.InitLog() + logs.InitLog("") id1 := "123123123" name1 := "test_name" @@ -58,7 +58,7 @@ func TestListResources(t *testing.T) { func TestListAllResourcesFromRMS(t *testing.T) { patches := getPatches() defer patches.Reset() - logs.InitLog() + logs.InitLog("") id1 := "123123123" name1 := "test_name" @@ -100,3 +100,29 @@ func TestListAllResourcesFromRMS(t *testing.T) { assert.Nil(t, err) assert.Equal(t, 2, len(resources)) } + +func TestListEmptyResources(t *testing.T) { + patches := getPatches() + defer patches.Reset() + logs.InitLog("") + + currentNum := int32(0) + response := model.ListResourcesResponse{ + Resources: &[]model.ResourceEntity{}, + PageInfo: &model.PageInfo{ + CurrentCount: ¤tNum, + }, + } + endpointConfig = map[string]string{ + "rms": "https://rms.myhuaweicloud.com", + } + + patches.ApplyMethodFunc(getRMSClient(), "ListResources", func(request *model.ListResourcesRequest) (*model.ListResourcesResponse, error) { + return &response, nil + }) + + CloudConf.Global.EpIds = "0" + resources, err := listResources("ecs", "cloudservers") + assert.Nil(t, err) + assert.Equal(t, 0, len(resources)) +} diff --git a/collector/utils.go b/collector/utils.go index e840fecc..ddb62326 100644 --- a/collector/utils.go +++ b/collector/utils.go @@ -21,6 +21,8 @@ import ( ) const MinimumResourceInfoSyncInterval = 10 +const MaxNamespacesCount = 1000 +const MaxEpsCount = 10000 var tagRegexp *regexp.Regexp @@ -206,7 +208,7 @@ func buildDimensionMetrics(metricNames []string, namespace string, dimensions [] } func getHcClient(endpoint string) *core.HcHttpClient { - return core.NewHcHttpClient(impl.NewDefaultHttpClient(config.DefaultHttpConfig().WithIgnoreSSLVerification(true))). + return core.NewHcHttpClient(impl.NewDefaultHttpClient(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify))). WithCredential(basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). WithEndpoints([]string{endpoint}) } diff --git a/collector/version.go b/collector/version.go index 21f53f58..be61d263 100644 --- a/collector/version.go +++ b/collector/version.go @@ -1,5 +1,5 @@ package collector const ( - Version = "v2.0.9" + Version = "v2.0.10" ) diff --git a/collector/waf.go b/collector/waf.go index f89d1237..e6c899da 100644 --- a/collector/waf.go +++ b/collector/waf.go @@ -75,7 +75,7 @@ func getAllWafInstancesFromRMS() ([]ResourceBaseInfo, error) { func getWAFClient() *waf.WafClient { return waf.NewWafClient(waf.WafClientBuilder().WithCredential( basic.NewCredentialsBuilder().WithAk(conf.AccessKey).WithSk(conf.SecretKey).WithProjectId(conf.ProjectID).Build()). - WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(true)). + WithHttpConfig(config.DefaultHttpConfig().WithIgnoreSSLVerification(CloudConf.Global.IgnoreSSLVerify)). WithEndpoint(getEndpoint("waf", "v1")).Build()) } diff --git a/collector/waf_test.go b/collector/waf_test.go index 194d4815..4a62b737 100644 --- a/collector/waf_test.go +++ b/collector/waf_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/agiledragon/gomonkey/v2" + "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model" "github.com/stretchr/testify/assert" "github.com/huaweicloud/cloudeye-exporter/logs" - "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model" ) func TestWAFInfo_GetResourceInfo(t *testing.T) { @@ -56,7 +56,7 @@ func TestWAFInfo_GetResourceInfo(t *testing.T) { patches.ApplyFuncReturn(getMetricConfigMap, sysConfig) patches.ApplyFuncReturn(listResources, mockRmsResource(), errors.New("")) - logs.InitLog() + logs.InitLog("") } getter := WAFInfo{} got, got1 := getter.GetResourceInfo() @@ -104,7 +104,7 @@ func TestWafGetResourceInfo_getAllWafInstancesFromRMSErr(t *testing.T) { patches.ApplyFuncReturn(getMetricConfigMap, sysConfig) patches.ApplyFuncReturn(listResources, mockRmsResource(), errors.New("")) - logs.InitLog() + logs.InitLog("") var wafGetter WAFInfo labels, metrics := wafGetter.GetResourceInfo() assert.Nil(t, labels) @@ -135,7 +135,7 @@ func TestWafGetResourceInfo_getAllPremiumWafInstancesNormal(t *testing.T) { }, } patches = gomonkey.ApplyMethodReturn(wafClient, "ListInstance", resp, nil) - logs.InitLog() + logs.InitLog("") var wafGetter WAFInfo labels, metrics := wafGetter.GetResourceInfo() assert.Equal(t, 2, len(labels)) @@ -167,7 +167,7 @@ func TestWafGetResourceInfo_getAllPremiumWafInstancesErr(t *testing.T) { } patches = gomonkey.ApplyMethodReturn(wafClient, "ListInstance", resp, errors.New("")) - logs.InitLog() + logs.InitLog("") var wafGetter WAFInfo labels, metrics := wafGetter.GetResourceInfo() assert.Nil(t, labels) @@ -213,7 +213,7 @@ func Test_getAllPremiumWafInstances(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { patches := getPatches() - logs.InitLog() + logs.InitLog("") if tt.name == "normal" { wafClient := getWAFClient() resp := &model.ListInstanceResponse{ diff --git a/grafana_dashboard/templates/css(es)_dashboard_template.json b/grafana_dashboard/templates/css(es)_dashboard_template.json index 0a13f627..29b85f89 100644 --- a/grafana_dashboard/templates/css(es)_dashboard_template.json +++ b/grafana_dashboard/templates/css(es)_dashboard_template.json @@ -17,16 +17,6 @@ "id": 26, "iteration": 1652276608030, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/templates/dcaas_dashboard_template.json b/grafana_dashboard/templates/dcaas_dashboard_template.json index 08e5e1b3..40cecc70 100644 --- a/grafana_dashboard/templates/dcaas_dashboard_template.json +++ b/grafana_dashboard/templates/dcaas_dashboard_template.json @@ -17,16 +17,6 @@ "id": 27, "iteration": 1652182368763, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/templates/dcs_dashboard_template.json b/grafana_dashboard/templates/dcs_dashboard_template.json index f703ebf9..f01df0f9 100644 --- a/grafana_dashboard/templates/dcs_dashboard_template.json +++ b/grafana_dashboard/templates/dcs_dashboard_template.json @@ -17,16 +17,6 @@ "id": 29, "iteration": 1652274359514, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/templates/dds_dashboard_template.json b/grafana_dashboard/templates/dds_dashboard_template.json index 56ba8f43..886fdf9d 100644 --- a/grafana_dashboard/templates/dds_dashboard_template.json +++ b/grafana_dashboard/templates/dds_dashboard_template.json @@ -65,16 +65,6 @@ "graphTooltip": 0, "id": null, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/templates/dms(Kafka)_dashboard_template.json b/grafana_dashboard/templates/dms(Kafka)_dashboard_template.json index c653768f..082e8b2d 100644 --- a/grafana_dashboard/templates/dms(Kafka)_dashboard_template.json +++ b/grafana_dashboard/templates/dms(Kafka)_dashboard_template.json @@ -65,16 +65,6 @@ "graphTooltip": 0, "id": null, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/templates/elb_dashboard_template.json b/grafana_dashboard/templates/elb_dashboard_template.json index 86f47901..747deaaa 100644 --- a/grafana_dashboard/templates/elb_dashboard_template.json +++ b/grafana_dashboard/templates/elb_dashboard_template.json @@ -17,16 +17,6 @@ "id": 24, "iteration": 1652275324173, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/templates/gaussdb(mysql)_dashboard_template.json b/grafana_dashboard/templates/gaussdb(mysql)_dashboard_template.json new file mode 100644 index 00000000..38cf6adb --- /dev/null +++ b/grafana_dashboard/templates/gaussdb(mysql)_dashboard_template.json @@ -0,0 +1,1879 @@ +{ + "__inputs": [ + { + "name": "DS_3VI-GAUSS-TEST-PROMETHEUS", + "label": "3vi-gauss-test-prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "description": "【华为云GAUSSDB(for MySql)监控指标说明】https://support.huaweicloud.com/usermanual-gaussdbformysql/gaussdbformysql_03_0085.html", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1718955204901, + "links": [], + "panels": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "displayMode": "color-background", + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(0, 0, 0, 0)", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "是否是主节点" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 + }, + { + "id": "mappings", + "value": [ + { + "from": "", + "id": 1, + "text": "是", + "to": "", + "type": 1, + "value": "master" + }, + { + "from": "", + "id": 2, + "text": "否", + "to": "", + "type": 1, + "value": "slave" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU使用率" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.width", + "value": 100 + }, + { + "id": "color" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 60 + }, + { + "color": "red", + "value": 85 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "网络输入吞吐量" + }, + "properties": [ + { + "id": "unit", + "value": "Bps" + }, + { + "id": "custom.width", + "value": 120 + }, + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "网络输出吞吐量" + }, + "properties": [ + { + "id": "unit", + "value": "Bps" + }, + { + "id": "custom.width", + "value": 120 + }, + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存使用率" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.width", + "value": 100 + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 60 + }, + { + "color": "red", + "value": 85 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "数据库总连接数" + }, + "properties": [ + { + "id": "custom.width", + "value": 120 + }, + { + "id": "color" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 50 + }, + { + "color": "red", + "value": 100 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "当前活跃连接数" + }, + "properties": [ + { + "id": "custom.width", + "value": 120 + }, + { + "id": "color" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 20 + }, + { + "color": "red", + "value": 40 + } + ] + } + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 16, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "7.5.17", + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "editorMode": "code", + "exemplar": false, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql001_cpu_util{epId=~\"$EPS\"}", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "range": false, + "refId": "A" + }, + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "editorMode": "code", + "exemplar": false, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql002_mem_util{epId=~\"$EPS\"}", + "format": "table", + "hide": false, + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "B" + }, + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "editorMode": "code", + "exemplar": false, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql004_bytes_in{epId=~\"$EPS\"}", + "format": "table", + "hide": false, + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "C" + }, + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "editorMode": "code", + "exemplar": false, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql005_bytes_out{epId=~\"$EPS\"}", + "format": "table", + "hide": false, + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "D" + }, + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "editorMode": "code", + "exemplar": false, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql006_conn_count{epId=~\"$EPS\"}", + "format": "table", + "hide": false, + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "E" + }, + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "editorMode": "code", + "exemplar": false, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql007_conn_active_count{epId=~\"$EPS\"}", + "format": "table", + "hide": false, + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "F" + } + ], + "title": "GaussDB For Mysql资源总览【企业项目: $EPS,实例总数:$total】", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "engineName", + "innerIp", + "instanceName", + "name", + "role", + "Value #A", + "Value #B", + "Value #C", + "Value #D", + "Value #E", + "Value #F" + ] + } + } + }, + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": {}, + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "Value #A": "CPU使用率", + "Value #B": "内存使用率", + "Value #C": "网络输入吞吐量", + "Value #D": "网络输出吞吐量", + "Value #E": "数据库总连接数", + "Value #F": "当前活跃连接数", + "engineName": "数据库引擎", + "innerIp": "内网IP", + "innerPort": "", + "instanceName": "实例名称", + "name": "节点名称", + "role": "是否是主节点" + } + } + } + ], + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "decimals": null, + "description": "云数据库GaussDB(for mysql):该指标用于统计测量对象的CPU利用率", + "fieldConfig": { + "defaults": { + "unit": "percent" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "hideEmpty": false, + "hideZero": false, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql001_cpu_util{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-CPU使用率", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU使用率", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计测量对象的内存利用率", + "fieldConfig": { + "defaults": { + "unit": "percent" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 9 + }, + "hiddenSeries": false, + "id": 3, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql002_mem_util{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-内存使用率", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "内存使用率", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计平均每秒从测量对象的所有网络适配器输入的流量", + "fieldConfig": { + "defaults": { + "unit": "Bps" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 18 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql004_bytes_in{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-网络输入吞吐量", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "网络输入吞吐量", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计平均每秒从测量对象的所有网络适配器输出的流量", + "fieldConfig": { + "defaults": { + "unit": "Bps" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 18 + }, + "hiddenSeries": false, + "id": 5, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql005_bytes_out{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-网络输出吞吐量", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "网络输出吞吐量", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计连接到MySQL服务器的总连接数", + "fieldConfig": { + "defaults": { + "unit": "none" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 27 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql006_conn_count{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-数据库总连接数", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "数据库总连接数", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计当前活跃的连接数", + "fieldConfig": { + "defaults": { + "unit": "none" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 27 + }, + "hiddenSeries": false, + "id": 7, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql007_conn_active_count{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-当前活跃连接数", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "当前活跃连接数", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计事务执行次数,含提交的和回退的", + "fieldConfig": { + "defaults": { + "unit": "次/秒" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 36 + }, + "hiddenSeries": false, + "id": 8, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql009_tps{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-事务执行频次", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "事务执行频次", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "次/秒", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计数据库每秒执行select SQL语句数", + "fieldConfig": { + "defaults": { + "unit": "次/秒" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 36 + }, + "hiddenSeries": false, + "id": 9, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql008_qps{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-query语句执行频率", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "query语句执行频率", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "次/秒", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计平均每秒Insert语句执行次数", + "fieldConfig": { + "defaults": { + "unit": "次/秒" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 45 + }, + "hiddenSeries": false, + "id": 10, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql029_comdml_ins_count{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-insert语句执行频率", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Insert语句执行频率", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "次/秒", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计平均每秒Delete语句执行次数", + "fieldConfig": { + "defaults": { + "unit": "次/秒" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 45 + }, + "hiddenSeries": false, + "id": 11, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql028_comdml_del_count{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-Delete语句执行频率", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Delete语句执行频率", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "次/秒", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计平均每秒Update语句执行次数", + "fieldConfig": { + "defaults": { + "unit": "次/秒" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 54 + }, + "hiddenSeries": false, + "id": 12, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql034_comdml_upd_count{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-Update语句执行频率", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Update语句执行频率", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "次/秒", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于展示每分钟MySQL产生慢日志的数量", + "fieldConfig": { + "defaults": { + "unit": "个/分钟" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 54 + }, + "hiddenSeries": false, + "id": 13, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql074_slow_queries{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-慢日志个数统计", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "慢日志个数统计", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "个/分钟", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计IO写入的IOPS。", + "fieldConfig": { + "defaults": { + "unit": "cps" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 63 + }, + "hiddenSeries": false, + "id": 14, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql342_iostat_iops_write{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-IO写IOPS", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "IO写IOPS", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "cps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "description": "云数据库GaussDB(for mysql):该指标用于统计IO读取的IOPS。", + "fieldConfig": { + "defaults": { + "unit": "cps" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 63 + }, + "hiddenSeries": false, + "id": 15, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.17", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "exemplar": true, + "expr": "huaweicloud_sys_gaussdb_gaussdb_mysql344_iostat_iops_read{epId=~\"$EPS\"} - 0", + "interval": "", + "legendFormat": "{{innerIp}}({{name}})-IO读IOPS", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "IO读IOPS", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "cps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": false, + "schemaVersion": 27, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "definition": "huaweicloud_epinfo", + "description": null, + "error": null, + "hide": 0, + "includeAll": false, + "label": "企业项目", + "multi": false, + "name": "EPS", + "options": [], + "query": { + "query": "huaweicloud_epinfo", + "refId": "3vi-gauss-test-prometheus-EPS-Variable-Query" + }, + "refresh": 1, + "regex": "/epName=\"(?[^\"]+)|epId=\"(?[^\"]+)/g", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_3VI-GAUSS-TEST-PROMETHEUS}", + "definition": "query_result(count(huaweicloud_sys_gaussdb_gaussdb_mysql001_cpu_util{epId=~\"$EPS\"}))", + "description": null, + "error": null, + "hide": 2, + "includeAll": false, + "label": null, + "multi": false, + "name": "total", + "options": [], + "query": { + "query": "query_result(count(huaweicloud_sys_gaussdb_gaussdb_mysql001_cpu_util{epId=~\"$EPS\"}))", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "/{} (.*) .*/", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "GaussDB For Mysql", + "uid": "PkQqyyUSa", + "version": 3 +} \ No newline at end of file diff --git a/grafana_dashboard/templates/rds_dashboard_template.json b/grafana_dashboard/templates/rds_dashboard_template.json index 90e29f9b..0ddbadf2 100644 --- a/grafana_dashboard/templates/rds_dashboard_template.json +++ b/grafana_dashboard/templates/rds_dashboard_template.json @@ -17,16 +17,6 @@ "id": 25, "iteration": 1652184667477, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/templates/vpc_dashboard_template.json b/grafana_dashboard/templates/vpc_dashboard_template.json index 2ab47e11..4beb2766 100644 --- a/grafana_dashboard/templates/vpc_dashboard_template.json +++ b/grafana_dashboard/templates/vpc_dashboard_template.json @@ -17,16 +17,6 @@ "id": 7, "iteration": 1660535145197, "links": [ - { - "$$hashKey": "object:2301", - "icon": "question", - "tags": [], - "targetBlank": true, - "title": "GitHub", - "tooltip": "查看更多仪表板", - "type": "link", - "url": "https://github.com/starsliao" - }, { "$$hashKey": "object:2302", "asDropdown": true, diff --git a/grafana_dashboard/use_grafana_template.md b/grafana_dashboard/use_grafana_template.md index 06a80735..3a4ac4dd 100644 --- a/grafana_dashboard/use_grafana_template.md +++ b/grafana_dashboard/use_grafana_template.md @@ -50,6 +50,7 @@ + [DDOS高防 DDOS](templates/ddos_dashboard_template.json) + [内容分发网络 CDN](templates/cdn_dashboard_template.json) + [云硬盘 EVS](templates/evs_dashboard_template.json) + + [云数据库 GaussDB(for MySQL)](templates/gaussdb(mysql)_dashboard_template.json) 4. 效果展示: >ECS: > ![img.png](pic/ecs.jpg) diff --git a/logs/logs.go b/logs/logs.go index f0fc0210..f6117373 100644 --- a/logs/logs.go +++ b/logs/logs.go @@ -77,9 +77,9 @@ func (c ConfLoader) LoadData(data []byte, cfg interface{}) error { return err } -func InitLog() { +func InitLog(logsConfPath string) { var cfg map[string][]Config - err := newYamlLoader().LoadFile("./logs.yml", &cfg) + err := newYamlLoader().LoadFile(logsConfPath, &cfg) if err != nil { fmt.Printf("Fail to load logs.yml, error: %s", err.Error()) return diff --git a/logs/logs_test.go b/logs/logs_test.go new file mode 100644 index 00000000..a8f1c518 --- /dev/null +++ b/logs/logs_test.go @@ -0,0 +1,44 @@ +package logs + +import ( + "errors" + "testing" + + "github.com/agiledragon/gomonkey/v2" + "github.com/stretchr/testify/assert" +) + +func TestInitLog(t *testing.T) { + successFlag := true + testCases := []struct { + name string + patches func() *gomonkey.Patches + expect func(t *testing.T) + }{ + { + "error_case", + func() *gomonkey.Patches { + patches := gomonkey.NewPatches() + confLoader := &ConfLoader{} + patches.ApplyMethod(confLoader, "LoadFile", func(c *ConfLoader, fPath string, cfg interface{}) error { + successFlag = false + return errors.New("path error") + }) + patches.ApplyFuncReturn(newYamlLoader, confLoader) + return patches + }, + func(t *testing.T) { + assert.True(t, successFlag) + }, + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + patches := testCase.patches() + defer patches.Reset() + InitLog("/logs.yml") + testCase.expect(t) + }) + } +} diff --git a/main.go b/main.go index f8994760..79c1d830 100644 --- a/main.go +++ b/main.go @@ -17,9 +17,10 @@ import ( var ( clientConfig = flag.String("config", "./clouds.yml", "Path to the cloud configuration file") - securityMod = flag.Bool("s", false, "Get ak sk from command line") - getVersion = flag.Bool("v", false, "Get version from command line") - ak, sk string + // 安全模式,从用户交互输入获取ak/sk,避免明文ak/sk敏感信息存储在配置文件中 + securityMod = flag.Bool("s", false, "Get ak sk from command line") + getVersion = flag.Bool("v", false, "Get version from command line") + ak, sk string ) func handler(w http.ResponseWriter, r *http.Request) { @@ -30,8 +31,11 @@ func handler(w http.ResponseWriter, r *http.Request) { } targets := strings.Split(target, ",") + if len(targets) > collector.MaxNamespacesCount { + http.Error(w, "namespaces not allowed to exceed 1000", 400) + return + } registry := prometheus.NewRegistry() - logs.Logger.Infof("Start to monitor services: %s", targets) exporter := collector.GetMonitoringCollector(targets) registry.MustRegister(exporter) @@ -55,10 +59,11 @@ func epHandler(w http.ResponseWriter, r *http.Request) { func getAkSkFromCommandLine() { if *securityMod { collector.SecurityMod = *securityMod + // 用户交互输入ak/sk,避免明文配置敏感信息 fmt.Print("Please input ak&sk split with space: (eg: {example_ak example_sk})") _, err := fmt.Scanln(&ak, &sk) if err != nil { - logs.Logger.Error("Read ak sk error: ", err.Error()) + fmt.Printf("Read ak sk error: %s", err.Error()) return } collector.TmpAK = ak @@ -68,7 +73,7 @@ func getAkSkFromCommandLine() { func getVersionFunc() { if *getVersion { - fmt.Printf("cloudeye-exporter version: %s", collector.Version) + fmt.Printf("Cloudeye-exporter version: %s", collector.Version) os.Exit(0) } } @@ -76,18 +81,8 @@ func getVersionFunc() { func main() { flag.Parse() getVersionFunc() - logs.InitLog() getAkSkFromCommandLine() - err := collector.InitCloudConf(*clientConfig) - if err != nil { - logs.Logger.Error("Init Cloud Config From File error: ", err.Error()) - logs.FlushLogAndExit(1) - } - err = collector.InitMetricConf() - if err != nil { - logs.Logger.Error("Init metric Config error: ", err.Error()) - logs.FlushLogAndExit(1) - } + initConf() http.HandleFunc(collector.CloudConf.Global.MetricPath, handler) http.HandleFunc(collector.CloudConf.Global.EpsInfoPath, epHandler) @@ -102,3 +97,19 @@ func main() { logs.FlushLogAndExit(1) } } + +func initConf() { + err := collector.InitCloudConf(*clientConfig) + if err != nil { + fmt.Printf("Init Cloud Config From File error: %s", err.Error()) + os.Exit(1) + } + + logs.InitLog(collector.CloudConf.Global.LogsConfPath) + err = collector.InitMetricConf() + if err != nil { + logs.Logger.Errorf("Init metric Config error: %s", err.Error()) + logs.FlushLogAndExit(1) + } + collector.InitEndpointConfig(collector.CloudConf.Global.EndpointsConfPath) +} diff --git a/metric.yml b/metric.yml index be2ffd67..6bacf57f 100644 --- a/metric.yml +++ b/metric.yml @@ -815,6 +815,9 @@ SYS.NAT: - snat_connection_ratio - inbound_bandwidth_ratio - outbound_bandwidth_ratio + - package_drop_count_eip_port_alloc_beyond + - package_drop_count_pps_beyond + - package_drop_count_snat_connection_beyond SYS.AS: dim_metric_name: AutoScalingGroup: @@ -1141,8 +1144,11 @@ SYS.NoSQL: - cassandra004_bytes_in - cassandra014_connections - cassandra015_read_latency + - nosql005_disk_usage - cassandra016_write_latency + - nosql006_disk_total_size - cassandra037_pending_write + - nosql007_disk_used_size - cassandra038_pending_read - cassandra044_range_slice_latency - cassandra049_dropped_mutation @@ -1168,656 +1174,566 @@ SYS.NoSQL: - cassandra165_large_partition_num - cassandra166_write_max_latency - cassandra167_read_max_latency - - nosql005_disk_usage - - nosql006_disk_total_size - - nosql007_disk_used_size - cassandra168_imbalance_table_num - nosql009_dfv_write_delay - nosql010_dfv_read_delay + - cassandra169_modify_request_size_mean + - cassandra170_query_response_size_mean + - cassandra171_batch_warn_count + - cassandra172_batch_fail_count + - cassandra173_limit_diff_count_mean + - cassandra174_tombstone_query_rate + - cassandra175_single_delete_rate + - cassandra176_range_delete_rate + - cassandra177_large_row_count + - cassandra175_max_sync_delay + redis_cluster_id: + - redis667_cluster_qps + - redis668_cluster_key_counts + - redis688_qps_send_total + - redis689_qps_receive_total + - redis798_cluster_expire_key_counts + - redis799_cluster_max_request_bytes + - redis800_cluster_max_request_argc + - redis801_cluster_max_response_bytes + - redis802_cluster_max_response_argc + - redis803_cluster_all_avg_usec + - redis804_cluster_all_p99_usec + - redis805_cluster_avg_hit_rate + - redis806_cluster_max_connection_usage + - redis807_cluster_all_connection_count + - redis808_cluster_new_client_connection + - redis811_cluster_max_connect_count + - redis812_cluster_processed_command_count + - redis813_cluster_slow_query_count + - redis814_cluster_mem_usage + - redis815_cluster_cpu_usage + - redis816_cluster_disk_usage + - redis820_cluster_in_bandwidth_usage + - redis821_cluster_out_bandwidth_usage + - redis822_cluster_cmd_err_num + - redis823_cluster_persist_key_num + - redis831_cluster_dbcache_total_ops + - redis832_cluster_dbcache_binlog_delay + - redis833_cluster_dbcache_replication_delay + - redis834_cluster_dbcache_recv_bps redis_cluster_id,redis_node_id: + - gemini001_cpu_usage + - redis661_rsync_ops + - redis669_connection_usage - nosql001_cpu_usage + - redis662_rsync_wal_size + - redis670_hit_rate - nosql002_mem_usage - - gemini001_cpu_usage - - gemini002_mem_usage + - redis663_rsync_push_cost + - redis664_rsync_send_cost + - redis017_proxy_accept + - redis665_rsync_max_push_cost - nosql005_disk_usage + - redis018_proxy_resqust_ps + - redis666_rsync_max_send_cost - nosql006_disk_total_size + - redis019_proxy_response_ps - nosql007_disk_used_size + - redis032_shard_qps - gemini003_bytes_out - gemini004_bytes_in - redis020_proxy_recv_client_bps - redis021_proxy_send_client_bps - - redis022_proxy_send_server_bps - - redis023_proxy_recv_server_bps - - redis017_proxy_accept - - redis018_proxy_resqust_ps - - redis019_proxy_response_ps - - redis032_shard_qps + - redis024_rocksdb_db_memtable_usage + - redis025_rocksdb_db_tablereader_usage + - redis026_rocksdb_block_cache_usage - redis027_rocksdb_iter_pin_block_usage + - redis028_rocksdb_mem_usage + - redis029_stream_iops + - redis030_stream_rbps + - redis031_stream_wbs - redis316_all_avg_usec - redis317_all_max_usec - redis318_all_p99 - redis319_all_qps - redis036_exists_avg_usec - - redis037_exists_max_usec - redis038_exists_p99 - redis039_exists_qps - redis040_expire_avg_usec - - redis041_expire_max_usec - redis042_expire_p99 - redis043_expire_qps - redis044_del_avg_usec - - redis045_del_max_usec - redis046_del_p99 - redis047_del_qps - redis048_ttl_avg_usec - - redis049_ttl_max_usec - redis050_ttl_p99 - redis051_ttl_qps - redis052_persist_avg_usec - - redis053_persist_max_usec - redis054_persist_p99 - redis055_persist_qps - redis056_scan_avg_usec - - redis057_scan_max_usec - redis058_scan_p99 - redis059_scan_qps - redis060_set_avg_usec - - redis061_set_max_usec - redis062_set_p99 - redis063_set_qps - redis064_get_avg_usec - - redis065_get_max_usec - redis066_get_p99 - redis067_get_qps - redis068_getset_avg_usec - - redis069_getset_max_usec - redis070_getset_p99 - redis071_getset_qps - redis072_append_avg_usec - - redis073_append_max_usec - redis074_append_p99 - redis075_append_qps - redis076_mget_avg_usec - - redis077_mget_max_usec - redis078_mget_p99 - redis079_mget_qps - redis080_mset_avg_usec - - redis081_mset_max_usec - redis082_mset_p99 - redis083_mset_qps - redis084_getrange_avg_usec - - redis085_getrange_max_usec - redis086_getrange_p99 - redis087_getrange_qps - redis088_setrange_avg_usec - - redis089_setrange_max_usec - redis090_setrange_p99 - redis091_setrange_qps - redis092_substr_avg_usec - - redis093_substr_max_usec - redis094_substr_p99 - redis095_substr_qps - redis096_strlen_avg_usec - - redis097_strlen_max_usec - redis098_strlen_p99 - redis099_strlen_qps - redis100_incr_avg_usec - - redis101_incr_max_usec - redis102_incr_p99 - redis103_incr_qps - redis104_decr_avg_usec - - redis105_decr_max_usec - redis106_decr_p99 - redis107_decr_qps - redis108_hset_avg_usec - - redis109_hset_max_usec - redis110_hset_p99 - redis111_hset_qps - redis112_hget_avg_usec - - redis113_hget_max_usec - redis114_hget_p99 - redis115_hget_qps - redis116_hmset_avg_usec - - redis117_hmset_max_usec - redis118_hmset_p99 - redis119_hmset_qps - redis120_hmget_avg_usec - - redis121_hmget_max_usec - redis122_hmget_p99 - redis123_hmget_qps - redis124_hdel_avg_usec - - redis125_hdel_max_usec - redis126_hdel_p99 - redis127_hdel_qps - redis128_hgetall_avg_usec - - redis129_hgetall_max_usec - redis130_hgetall_p99 - redis131_hgetall_qps - redis132_hexists_avg_usec - - redis133_hexists_max_usec - redis134_hexists_p99 - redis135_hexists_qps - redis136_hincrby_avg_usec - - redis137_hincrby_max_usec - redis138_hincrby_p99 - redis139_hincrby_qps - redis140_hkeys_avg_usec - - redis141_hkeys_max_usec - redis142_hkeys_p99 - redis143_hkeys_qps - redis144_hlen_avg_usec - - redis145_hlen_max_usec - redis146_hlen_p99 - redis147_hlen_qps - redis148_hstrlen_avg_usec - - redis149_hstrlen_max_usec - redis150_hstrlen_p99 - redis151_hstrlen_qps - redis152_hvals_avg_usec - - redis153_hvals_max_usec - redis154_hvals_p99 - redis155_hvals_qps - redis156_hscan_avg_usec - - redis157_hscan_max_usec - redis158_hscan_p99 - redis159_hscan_qps - redis160_lpush_avg_usec - - redis161_lpush_max_usec - redis162_lpush_p99 - redis163_lpush_qps - redis164_lpop_avg_usec - - redis165_lpop_max_usec - redis166_lpop_p99 - redis167_lpop_qps - redis168_rpush_avg_usec - - redis169_rpush_max_usec - redis170_rpush_p99 - redis171_rpush_qps - redis172_rpop_avg_usec - - redis173_rpop_max_usec - redis174_rpop_p99 - redis175_rpop_qps - redis176_rpoplpush_avg_usec - - redis177_rpoplpush_max_usec - redis178_rpoplpush_p99 - redis179_rpoplpush_qps - redis180_llen_avg_usec - - redis181_llen_max_usec - redis182_llen_p99 - redis183_llen_qps - redis184_lindex_avg_usec - - redis185_lindex_max_usec - redis186_lindex_p99 - redis187_lindex_qps - redis188_linsert_avg_usec - - redis189_linsert_max_usec - redis190_linsert_p99 - redis191_linsert_qps - redis192_lrange_avg_usec - - redis193_lrange_max_usec - redis194_lrange_p99 - redis195_lrange_qps - redis196_lrem_avg_usec - - redis197_lrem_max_usec - redis198_lrem_p99 - redis199_lrem_qps - redis200_lset_avg_usec - - redis201_lset_max_usec - redis202_lset_p99 - redis203_lset_qps - redis204_ltrim_avg_usec - - redis205_ltrim_max_usec - redis206_ltrim_p99 - redis207_ltrim_qps - redis208_sadd_avg_usec - - redis209_sadd_max_usec - redis210_sadd_p99 - redis211_sadd_qps - redis212_spop_avg_usec - - redis213_spop_max_usec - redis214_spop_p99 - redis215_spop_qps - redis216_scard_avg_usec - - redis217_scard_max_usec - redis218_scard_p99 - redis219_scard_qps - redis220_smembers_avg_usec - - redis221_smembers_max_usec - redis222_smembers_p99 - redis223_smembers_qps - redis224_srem_avg_usec - - redis225_srem_max_usec - redis226_srem_p99 - redis227_srem_qps - redis228_sunion_avg_usec - - redis229_sunion_max_usec - redis230_sunion_p99 - redis231_sunion_qps - redis232_sinter_avg_usec - - redis233_sinter_max_usec - redis234_sinter_p99 - redis235_sinter_qps - redis236_sismember_avg_usec - - redis237_sismember_max_usec - redis238_sismember_p99 - redis239_sismember_qps - redis240_sdiff_avg_usec - - redis241_sdiff_max_usec - redis242_sdiff_p99 - redis243_sdiff_qps - redis244_srandmember_avg_usec - - redis245_srandmember_max_usec - redis246_srandmember_p99 - redis247_srandmember_qps - redis248_zadd_avg_usec - - redis249_zadd_max_usec - redis250_zadd_p99 - redis251_zadd_qps - redis252_zcard_avg_usec - - redis253_zcard_max_usec - redis254_zcard_p99 - redis255_zcard_qps - redis256_zscan_avg_usec - - redis257_zscan_max_usec - redis258_zscan_p99 - redis259_zscan_qps - redis260_zincrby_avg_usec - - redis261_zincrby_max_usec - redis262_zincrby_p99 - redis263_zincrby_qps - redis264_zrevrange_avg_usec - - redis265_zrevrange_max_usec - redis266_zrevrange_p99 - redis267_zrevrange_qps - redis268_zrange_avg_usec - - redis269_zrange_max_usec - redis270_zrange_p99 - redis271_zrange_qps - redis272_zcount_avg_usec - - redis273_zcount_max_usec - redis274_zcount_p99 - redis275_zcount_qps - redis276_zrem_avg_usec - - redis277_zrem_max_usec - redis278_zrem_p99 - redis279_zrem_qps - redis280_zscore_avg_usec - - redis281_zscore_max_usec - redis282_zscore_p99 - redis283_zscore_qps - redis284_zrank_avg_usec - - redis285_zrank_max_usec - redis286_zrank_p99 - redis287_zrank_qps - redis288_zrevrank_avg_usec - - redis289_zrevrank_max_usec - redis290_zrevrank_p99 - redis291_zrevrank_qps - redis292_zlexcount_avg_usec - - redis293_zlexcount_max_usec - redis294_zlexcount_p99 - redis295_zlexcount_qps - redis296_zpopmax_avg_usec - - redis297_zpopmax_max_usec - redis298_zpopmax_p99 - redis299_zpopmax_qps - redis300_zpopmin_avg_usec - - redis301_zpopmin_max_usec - redis302_zpopmin_p99 - redis303_zpopmin_qps - redis304_zremrangebyrank_avg_usec - - redis305_zremrangebyrank_max_usec - redis306_zremrangebyrank_p99 - redis307_zremrangebyrank_qps - redis308_zremrangebyscore_avg_usec - - redis309_zremrangebyscore_max_usec - redis310_zremrangebyscore_p99 - redis311_zremrangebyscore_qps - redis312_zremrangebylex_avg_usec - - redis313_zremrangebylex_max_usec - redis314_zremrangebylex_p99 - redis315_zremrangebylex_qps - - redis320_exists_p9999 - - redis321_expire_p9999 - - redis322_del_p9999 - - redis323_ttl_p9999 - - redis324_persist_p9999 - - redis325_scan_p9999 - - redis326_set_p9999 - - redis327_get_p9999 - - redis328_getset_p9999 - - redis329_append_p9999 - - redis330_mget_p9999 - - redis331_mset_p9999 - - redis332_getrange_p9999 - - redis333_setrange_p9999 - - redis334_substr_p9999 - - redis335_strlen_p9999 - - redis336_incr_p9999 - - redis337_decr_p9999 - - redis338_hset_p9999 - - redis339_hget_p9999 - - redis340_hmset_p9999 - - redis341_hmget_p9999 - - redis342_hdel_p9999 - - redis343_hgetall_p9999 - - redis344_hexists_p9999 - - redis345_hincrby_p9999 - - redis346_hkeys_p9999 - - redis347_hlen_p9999 - - redis348_hstrlen_p9999 - - redis349_hvals_p9999 - - redis350_hscan_p9999 - - redis351_lpush_p9999 - - redis352_lpop_p9999 - - redis353_rpush_p9999 - - redis354_rpop_p9999 - - redis355_rpoplpush_p9999 - - redis356_llen_p9999 - - redis357_lindex_p9999 - - redis358_linsert_p9999 - - redis359_lrange_p9999 - - redis360_lrem_p9999 - - redis361_lset_p9999 - - redis362_ltrim_p9999 - - redis363_sadd_p9999 - - redis364_spop_p9999 - - redis365_scard_p9999 - - redis366_smembers_p9999 - - redis367_srem_p9999 - - redis368_sunion_p9999 - - redis369_sinter_p9999 - - redis370_sismember_p9999 - - redis371_sdiff_p9999 - - redis372_srandmember_p9999 - - redis373_zadd_p9999 - - redis374_zcard_p9999 - - redis375_zscan_p9999 - - redis376_zincrby_p9999 - - redis377_zrevrange_p9999 - - redis378_zrange_p9999 - - redis379_zcount_p9999 - - redis380_zrem_p9999 - - redis381_zscore_p9999 - - redis382_zrank_p9999 - - redis383_zrevrank_p9999 - - redis384_zlexcount_p9999 - - redis385_zpopmax_p9999 - - redis386_zpopmin_p9999 - - redis387_zremrangebyrank_p9999 - - redis388_zremrangebyscore_p9999 - - redis389_zremrangebylex_p9999 - - redis390_all_p9999 - redis391_ping_avg_usec - - redis392_ping_max_usec - redis393_ping_p99 - - redis394_ping_p9999 - redis395_ping_qps - redis396_info_avg_usec - - redis397_info_max_usec - redis398_info_p99 - - redis399_info_p9999 - redis400_info_qps - redis401_type_avg_usec - - redis402_type_max_usec - redis403_type_p99 - - redis404_type_p9999 - redis405_type_qps - redis406_randomkey_avg_usec - - redis407_randomkey_max_usec - redis408_randomkey_p99 - - redis409_randomkey_p9999 - redis410_randomkey_qps - redis411_setbit_avg_usec - - redis412_setbit_max_usec - redis413_setbit_p99 - - redis414_setbit_p9999 - redis415_setbit_qps - redis416_getbit_avg_usec - - redis417_getbit_max_usec - redis418_getbit_p99 - - redis419_getbit_p9999 - redis420_getbit_qps - redis421_bitcount_avg_usec - - redis422_bitcount_max_usec - redis423_bitcount_p99 - - redis424_bitcount_p9999 - redis425_bitcount_qps - redis426_bitpos_avg_usec - - redis427_bitpos_max_usec - redis428_bitpos_p99 - - redis429_bitpos_p9999 - redis430_bitpos_qps - redis431_bitop_avg_usec - - redis432_bitop_max_usec - redis433_bitop_p99 - - redis434_bitop_p9999 - redis435_bitop_qps - redis436_bitfield_avg_usec - - redis437_bitfield_max_usec - redis438_bitfield_p99 - - redis439_bitfield_p9999 - redis440_bitfield_qps - redis441_pfadd_avg_usec - - redis442_pfadd_max_usec - redis443_pfadd_p99 - - redis444_pfadd_p9999 - redis445_pfadd_qps - redis446_pfcount_avg_usec - - redis447_pfcount_max_usec - redis448_pfcount_p99 - - redis449_pfcount_p9999 - redis450_pfcount_qps - redis451_pfmerge_avg_usec - - redis452_pfmerge_max_usec - redis453_pfmerge_p99 - - redis454_pfmerge_p9999 - redis455_pfmerge_qps - redis456_blpop_avg_usec - - redis457_blpop_max_usec - redis458_blpop_p99 - - redis459_blpop_p9999 - redis460_blpop_qps - redis461_brpop_avg_usec - - redis462_brpop_max_usec - redis463_brpop_p99 - - redis464_brpop_p9999 - redis465_brpop_qps - redis466_brpoplpush_avg_usec - - redis467_brpoplpush_max_usec - redis468_brpoplpush_p99 - - redis469_brpoplpush_p9999 - redis470_brpoplpush_qps - redis471_sunionstore_avg_usec - - redis472_sunionstore_max_usec - redis473_sunionstore_p99 - - redis474_sunionstore_p9999 - redis475_sunionstore_qps - redis476_sinterstore_avg_usec - - redis477_sinterstore_max_usec - redis478_sinterstore_p99 - - redis479_sinterstore_p9999 - redis480_sinterstore_qps - redis481_sdiffstore_avg_usec - - redis482_sdiffstore_max_usec - redis483_sdiffstore_p99 - - redis484_sdiffstore_p9999 - redis485_sdiffstore_qps - redis486_zunionstore_avg_usec - - redis487_zunionstore_max_usec - redis488_zunionstore_p99 - - redis489_zunionstore_p9999 - redis490_zunionstore_qps - redis491_zinterstore_avg_usec - - redis492_zinterstore_max_usec - redis493_zinterstore_p99 - - redis494_zinterstore_p9999 - redis495_zinterstore_qps - redis496_geoadd_avg_usec - - redis497_geoadd_max_usec - redis498_geoadd_p99 - - redis499_geoadd_p9999 - redis500_geoadd_qps - redis501_georadiusbymember_avg_usec - - redis502_georadiusbymember_max_usec - redis503_georadiusbymember_p99 - - redis504_georadiusbymember_p9999 - redis505_georadiusbymember_qps - redis506_georadius_avg_usec - - redis507_georadius_max_usec - redis508_georadius_p99 - - redis509_georadius_p9999 - redis510_georadius_qps - redis511_geohash_avg_usec - - redis512_geohash_max_usec - redis513_geohash_p99 - - redis514_geohash_p9999 - redis515_geohash_qps - redis516_geodist_avg_usec - - redis517_geodist_max_usec - redis518_geodist_p99 - - redis519_geodist_p9999 - redis520_geodist_qps - redis521_geopos_avg_usec - - redis522_geopos_max_usec - redis523_geopos_p99 - - redis524_geopos_p9999 - redis525_geopos_qps - redis526_xadd_avg_usec - - redis527_xadd_max_usec - redis528_xadd_p99 - - redis529_xadd_p9999 - redis530_xadd_qps - redis531_xack_avg_usec - - redis532_xack_max_usec - redis533_xack_p99 - - redis534_xack_p9999 - redis535_xack_qps - redis536_xgroup_avg_usec - - redis537_xgroup_max_usec - redis538_xgroup_p99 - - redis539_xgroup_p9999 - redis540_xgroup_qps - redis541_xdel_avg_usec - - redis542_xdel_max_usec - redis543_xdel_p99 - - redis544_xdel_p9999 - redis545_xdel_qps - redis546_xtrim_avg_usec - - redis547_xtrim_max_usec - redis548_xtrim_p99 - - redis549_xtrim_p9999 - redis550_xtrim_qps - redis551_xlen_avg_usec - - redis552_xlen_max_usec - redis553_xlen_p99 - - redis554_xlen_p9999 - redis555_xlen_qps - redis556_xrange_avg_usec - - redis557_xrange_max_usec - redis558_xrange_p99 - - redis559_xrange_p9999 - redis560_xrange_qps - redis561_xrevrange_avg_usec - - redis562_xrevrange_max_usec - redis563_xrevrange_p99 - - redis564_xrevrange_p9999 - redis565_xrevrange_qps - redis566_xclaim_avg_usec - - redis567_xclaim_max_usec - redis568_xclaim_p99 - - redis569_xclaim_p9999 - redis570_xclaim_qps - redis571_xpending_avg_usec - - redis572_xpending_max_usec - redis573_xpending_p99 - - redis574_xpending_p9999 - redis575_xpending_qps - redis576_xinfo_avg_usec - - redis577_xinfo_max_usec - redis578_xinfo_p99 - - redis579_xinfo_p9999 - redis580_xinfo_qps - redis581_xread_avg_usec - - redis582_xread_max_usec - redis583_xread_p99 - - redis584_xread_p9999 - redis585_xread_qps - redis586_xreadgroup_avg_usec - - redis587_xreadgroup_max_usec - redis588_xreadgroup_p99 - - redis589_xreadgroup_p9999 - redis590_xreadgroup_qps - redis591_publish_avg_usec - - redis592_publish_max_usec - redis593_publish_p99 - - redis594_publish_p9999 - redis595_publish_qps - redis596_subscribe_avg_usec - - redis597_subscribe_max_usec - redis598_subscribe_p99 - - redis599_subscribe_p9999 - redis600_subscribe_qps - redis601_unsubscribe_avg_usec - - redis602_unsubscribe_max_usec - redis603_unsubscribe_p99 - - redis604_unsubscribe_p9999 - redis605_unsubscribe_qps - redis606_psubscribe_avg_usec - - redis607_psubscribe_max_usec - redis608_psubscribe_p99 - - redis609_psubscribe_p9999 - redis610_psubscribe_qps - redis611_punsubscribe_avg_usec - - redis612_punsubscribe_max_usec - redis613_punsubscribe_p99 - - redis614_punsubscribe_p9999 - redis615_punsubscribe_qps - redis616_pubsub_avg_usec - - redis617_pubsub_max_usec - redis618_pubsub_p99 - - redis619_pubsub_p9999 - redis620_pubsub_qps - redis621_eval_avg_usec - - redis622_eval_max_usec - redis623_eval_p99 - - redis624_eval_p9999 - redis625_eval_qps - redis626_evalsha_avg_usec - - redis627_evalsha_max_usec - redis628_evalsha_p99 - - redis629_evalsha_p9999 - redis630_evalsha_qps - redis631_script_avg_usec - - redis632_script_max_usec - redis633_script_p99 - - redis634_script_p9999 - redis635_script_qps - redis636_watch_avg_usec - - redis637_watch_max_usec - redis638_watch_p99 - - redis639_watch_p9999 - redis640_watch_qps - redis641_unwatch_avg_usec - - redis642_unwatch_max_usec - redis643_unwatch_p99 - - redis644_unwatch_p9999 - redis645_unwatch_qps - redis646_multi_avg_usec - - redis647_multi_max_usec - redis648_multi_p99 - - redis649_multi_p9999 - redis650_multi_qps - redis651_exec_avg_usec - - redis652_exec_max_usec - redis653_exec_p99 - - redis654_exec_p9999 - redis655_exec_qps - redis656_discard_avg_usec - - redis657_discard_max_usec - redis658_discard_p99 - - redis659_discard_p9999 - redis660_discard_qps + - redis671_new_client_connection + - redis672_no_auth + - redis673_wrong_auth + - redis674_max_pipelined + - redis675_max_request_bytes + - redis676_max_request_argc + - redis677_max_response_bytes + - redis678_max_response_argc + - redis679_proxy_to_client_rtt_avg + - redis680_proxy_to_client_rtt_max + - redis681_proxy_to_client_rtt_p99 + - redis682_client_packet_return_queue_avg + - redis683_client_packet_return_queue_max + - redis684_client_packet_return_queue_p99 + - redis685_client_network_packet_return_avg + - redis686_client_network_packet_return_max + - redis687_client_network_packet_return_p99 + - redis690_pingest_avg_usec + - redis692_pingest_p99 + - redis693_pingest_qps + - redis694_writesst_avg_usec + - redis696_writesst_p99 + - redis697_writesst_qps + - redis698_exhset_avg_usec + - redis700_exhset_p99 + - redis701_exhset_qps + - redis702_exhget_avg_usec + - redis704_exhget_p99 + - redis705_exhget_qps + - redis706_exhmset_avg_usec + - redis708_exhmset_p99 + - redis709_exhmset_qps + - redis710_exhpexpireat_avg_usec + - redis712_exhpexpireat_p99 + - redis713_exhpexpireat_qps + - redis714_exhpexpire_avg_usec + - redis716_exhpexpire_p99 + - redis717_exhpexpire_qps + - redis718_exhexpireat_avg_usec + - redis720_exhexpireat_p99 + - redis721_exhexpireat_qps + - redis722_exhexpire_avg_usec + - redis724_exhexpire_p99 + - redis725_exhexpire_qps + - redis726_exhpttl_avg_usec + - redis728_exhpttl_p99 + - redis729_exhpttl_qps + - redis730_exhttl_avg_usec + - redis732_exhttl_p99 + - redis733_exhttl_qps + - redis734_exhver_avg_usec + - redis736_exhver_p99 + - redis737_exhver_qps + - redis738_exhsetver_avg_usec + - redis740_exhsetver_p99 + - redis741_exhsetver_qps + - redis742_exhincrby_avg_usec + - redis744_exhincrby_p99 + - redis745_exhincrby_qps + - redis746_exhincrbyfloat_avg_usec + - redis748_exhincrbyfloat_p99 + - redis749_exhincrbyfloat_qps + - redis750_exhgetwithver_avg_usec + - redis752_exhgetwithver_p99 + - redis753_exhgetwithver_qps + - redis754_exhmget_avg_usec + - redis756_exhmget_p99 + - redis757_exhmget_qps + - redis758_exhmgetwithver_avg_usec + - redis760_exhmgetwithver_p99 + - redis761_exhmgetwithver_qps + - redis762_exhlen_avg_usec + - redis764_exhlen_p99 + - redis765_exhlen_qps + - redis766_exhexists_avg_usec + - redis768_exhexists_p99 + - redis769_exhexists_qps + - redis770_exhstrlen_avg_usec + - redis772_exhstrlen_p99 + - redis773_exhstrlen_qps + - redis774_exhkeys_avg_usec + - redis776_exhkeys_p99 + - redis777_exhkeys_qps + - redis778_exhvals_avg_usec + - redis780_exhvals_p99 + - redis781_exhvals_qps + - redis782_exhgetall_avg_usec + - redis784_exhgetall_p99 + - redis785_exhgetall_qps + - redis786_exhscan_avg_usec + - redis788_exhscan_p99 + - redis789_exhscan_qps + - redis790_exhscanunorder_avg_usec + - redis792_exhscanunorder_p99 + - redis793_exhscanunorder_qps + - redis794_exhdel_avg_usec + - redis796_exhdel_p99 + - redis797_exhdel_qps + - redis817_slow_query_count + - redis809_processed_command_count + - redis810_max_connect_count + - redis818_system_bytes_in_usage + - redis819_system_bytes_out_usage + - redis824_proxy_in_bandwidth_usage + - redis825_proxy_out_bandwidth_usage + - redis826_disk_iops + - redis827_disk_bandwidth + - redis828_disk_bandwidth_usage + - redis829_network_out + - redis830_network_in influxdb_cluster_id,influxdb_node_id: - gemini001_cpu_usage - gemini002_mem_usage @@ -1826,43 +1742,59 @@ SYS.NoSQL: - influxdb001_series_num - influxdb002_query_req_ps - influxdb003_write_req_ps - - influxdb004_write_points_ps - influxdb005_write_concurrency + - influxdb004_write_points_ps - influxdb006_query_concurrency - nosql005_disk_usage - nosql006_disk_total_size - nosql007_disk_used_size + - influxdb007_connection_num + - influxdb008_connection_usage + - influxdb009_slow_queries_num + - influxdb010_cold_disk_usage + - influxdb011_cold_disk_total_size + - influxdb012_cold_disk_used_size + mongodb_cluster_id: + - mongodb001_command_ps + - mongodb002_delete_ps + - mongodb003_insert_ps + - mongodb004_query_ps + - mongodb005_update_ps + - mongodb006_getmore_ps + - mongodb008_connections + - mongodb009_mig_fail_num mongodb_cluster_id,mongodb_node_id: - nosql001_cpu_usage - nosql002_mem_usage - nosql003_bytes_out + - nosql008_swap_usage - nosql004_bytes_in - nosql005_disk_usage - nosql006_disk_total_size - nosql007_disk_used_size - mongodb001_command_ps - mongodb002_delete_ps - - mongodb003_insert_ps - - mongodb004_query_ps - - mongodb005_update_ps - - mongodb006_getmore_ps - - mongodb007_connections - - mongodb007_connections_usage - mongodb008_mem_resident + - mongodb003_insert_ps - mongodb009_mem_virtual + - mongodb004_query_ps - mongodb010_regular_asserts_ps + - mongodb005_update_ps - mongodb011_warning_asserts_ps + - mongodb006_getmore_ps - mongodb012_msg_asserts_ps + - mongodb007_connections - mongodb013_user_asserts_ps - - mongodb017_page_faults - - mongodb019_cursors_open - - mongodb020_cursors_timeout - - mongodb026_repl_lag - - nosql008_swap_usage + - mongodb007_connections_usage + - mongodb008_connections - mongodb014_queues_total - mongodb015_queues_readers + - mongodb017_page_faults - mongodb016_queues_writers - mongodb018_porfling_num + - mongodb019_cursors_open + - mongodb020_cursors_timeout + - mongodb026_repl_lag SYS.DDOS: dim_metric_name: instance_id: