config

package
v0.0.0-...-f62340a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPeriodSeconds         = 60
	DefaultDelaySeconds          = 300
	DefaultReloadIntervalMinutes = 60
	DefaultRateLimit             = 15
	DefaultQueryMetricBatchSize  = 50

	EnvAccessKey   = "TENCENTCLOUD_SECRET_ID"
	EnvSecretKey   = "TENCENTCLOUD_SECRET_KEY"
	EnvServiceRole = "TENCENTCLOUD_SERVICE_ROLE"
	EnvRegion      = "TENCENTCLOUD_REGION"
)

Variables

View Source
var (
	Product2Namespace = map[string]string{
		"cmongo":        "QCE/CMONGO",
		"mongo":         "QCE/CMONGO",
		"cdb":           "QCE/CDB",
		"mysql":         "QCE/CDB",
		"cvm":           "QCE/CVM",
		"redis":         "QCE/REDIS",
		"redis_cluster": "QCE/REDIS",
		"redis_mem":     "QCE/REDIS_MEM",
		"cluster_redis": "QCE/REDIS",
		"dc":            "QCE/DC",
		"dcx":           "QCE/DCX",
		"lb_public":     "QCE/LB_PUBLIC",
		"public_clb":    "QCE/LB_PUBLIC",
		"loadbalance":   "QCE/LOADBALANCE",
		"7layer_clb":    "QCE/LOADBALANCE",
		"nat_gateway":   "QCE/NAT_GATEWAY",
		"nat":           "QCE/NAT_GATEWAY",
		"cos":           "QCE/COS",
		"cdn":           "QCE/CDN",
		"cbs":           "QCE/BLOCK_STORAGE",
		"sqlserver":     "QCE/SQLSERVER",
		"mariadb":       "QCE/MARIADB",
		"ces":           "QCE/CES",
		"cmq":           "QCE/CMQ",
		"cmqtopic":      "QCE/CMQTOPIC",
		"postgres":      "QCE/POSTGRES",
		"memcached":     "QCE/MEMCACHED",
		"lighthouse":    "QCE/LIGHTHOUSE",
		"ckafka":        "QCE/CKAFKA",
		"tdmysql":       "QCE/TDMYSQL",
		"lb":            "QCE/LB",
		"tdmq":          "QCE/TDMQ",
		"zookeeper":     "TSE/ZOOKEEPER",
		"nacos":         "TSE/NACOS",
		"vpngw":         "QCE/VPNGW",
		"vpnx":          "QCE/VPNX",
		"cynosdb_mysql": "QCE/CYNOSDB_MYSQL",
		"dts":           "QCE/DTS",
		"dcg":           "QCE/DCG",
		"vbc":           "QCE/VBC",
		"qaap":          "QCE/QAAP",
		"lb_private":    "QCE/LB_PRIVATE",
		"waf":           "QCE/WAF",
		"cfs":           "QCE/CFS",
	}

	SupportStatisticsTypes = map[string]bool{
		"max":  true,
		"min":  true,
		"avg":  true,
		"last": true,
	}
)
View Source
var QcloudNamespace = []string{"COS", "CDN", "QAAP", "WAF"}

Functions

func GetStandardNamespaceFromCustomNamespace

func GetStandardNamespaceFromCustomNamespace(cns string) string

Types

type TencentConfig

type TencentConfig struct {
	Credential           TencentCredential `yaml:"credential"`
	Metrics              []TencentMetric   `yaml:"metrics"`
	Products             []TencentProduct  `yaml:"products"`
	RateLimit            float64           `yaml:"rate_limit"`
	MetricQueryBatchSize int               `yaml:"metric_query_batch_size"`
	Filename             string            `yaml:"filename"`
	CacheInterval        int64             `yaml:"cache_interval"`   // 单位 s
	IsInternational      bool              `yaml:"is_international"` // true 表示是国际站
}

func NewConfig

func NewConfig() *TencentConfig

func (*TencentConfig) GetMetricConfigs

func (c *TencentConfig) GetMetricConfigs(namespace string) (mconfigs []TencentMetric)

func (*TencentConfig) GetNamespaces

func (c *TencentConfig) GetNamespaces() (nps []string)

func (*TencentConfig) GetProductConfig

func (c *TencentConfig) GetProductConfig(namespace string) (TencentProduct, error)

func (*TencentConfig) LoadFile

func (c *TencentConfig) LoadFile(filename string) error

type TencentCredential

type TencentCredential struct {
	AccessKey   string `yaml:"access_key"`
	SecretKey   string `yaml:"secret_key"`
	Role        string `yaml:"role"`
	Region      string `yaml:"region"`
	Token       string `yaml:"token"`
	ExpiredTime int64  `yaml:"expired_time"`
	IsInternal  bool   `yaml:"is_internal"`
}

type TencentMetric

type TencentMetric struct {
	Namespace      string            `yaml:"tc_namespace"`
	MetricName     string            `yaml:"tc_metric_name"`
	MetricReName   string            `yaml:"tc_metric_rename"`
	MetricNameType int32             `yaml:"tc_metric_name_type"` // 1=大写转下划线, 2=全小写
	Labels         []string          `yaml:"tc_labels"`
	Dimensions     map[string]string `yaml:"tc_myself_dimensions"`
	Filters        map[string]string `yaml:"tc_filters"`
	Statistics     []string          `yaml:"tc_statistics"`
	PeriodSeconds  int64             `yaml:"period_seconds"`
	RangeSeconds   int64             `yaml:"range_seconds"`
	DelaySeconds   int64             `yaml:"delay_seconds"`
}

type TencentProduct

type TencentProduct struct {
	Namespace             string              `yaml:"namespace"`
	AllMetrics            bool                `yaml:"all_metrics"`
	AllInstances          bool                `yaml:"all_instances"`
	ExtraLabels           []string            `yaml:"extra_labels"`
	OnlyIncludeMetrics    []string            `yaml:"only_include_metrics"`
	ExcludeMetrics        []string            `yaml:"exclude_metrics"`
	InstanceFilters       map[string]string   `yaml:"instance_filters"`
	OnlyIncludeInstances  []string            `yaml:"only_include_instances"`
	ExcludeInstances      []string            `yaml:"exclude_instances"`
	CustomQueryDimensions []map[string]string `yaml:"custom_query_dimensions"`
	Statistics            []string            `yaml:"statistics_types"`
	PeriodSeconds         int64               `yaml:"period_seconds"`
	RangeSeconds          int64               `yaml:"range_seconds"`
	DelaySeconds          int64               `yaml:"delay_seconds"`
	MetricNameType        int32               `yaml:"metric_name_type"` // 1=大写转下划线, 2=全小写
	ReloadIntervalMinutes int64               `yaml:"reload_interval_minutes"`
}

func (*TencentProduct) IsReloadEnable

func (p *TencentProduct) IsReloadEnable() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL