mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #11093 from zhaoxiangchun/automated-cherry-pick-of-#11025-upstream-release-3.7
Automated cherry pick of #11025: feat(monitor): add storage monitor metric
This commit is contained in:
@@ -144,4 +144,19 @@ var (
|
||||
"domain_id": "id",
|
||||
"project_domain": "name",
|
||||
}
|
||||
|
||||
StorageTags = map[string]string{
|
||||
"id": "storage_id",
|
||||
"name": "storage_name",
|
||||
"zone": "zone",
|
||||
"zone_id": "zone_id",
|
||||
"zone_ext_id": "zone_ext_id",
|
||||
"status": "status",
|
||||
"cloudregion": "cloudregion",
|
||||
"cloudregion_id": "cloudregion_id",
|
||||
"region_ext_id": "region_ext_id",
|
||||
"brand": "brand",
|
||||
"domain_id": "domain_id",
|
||||
"project_domain": "project_domain",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ const (
|
||||
METRIC_RES_TYPE_CLOUDACCOUNT = "cloudaccount"
|
||||
METRIC_RES_TYPE_TENANT = "tenant"
|
||||
METRIC_RES_TYPE_DOMAIN = "domain"
|
||||
METRIC_RES_TYPE_STORAGE = "storage"
|
||||
|
||||
METRIC_UNIT_PERCENT = "%"
|
||||
METRIC_UNIT_BPS = "bps"
|
||||
@@ -21,6 +22,7 @@ const (
|
||||
METRIC_UNIT_MS = "ms"
|
||||
METRIC_UNIT_BYTE = "byte"
|
||||
METRIC_UNIT_RMB = "RMB"
|
||||
METRIC_UNIT_MB = "Mb"
|
||||
|
||||
METRIC_DATABASE_TELE = "telegraf"
|
||||
METRIC_DATABASE_METER = "meter_db"
|
||||
@@ -38,6 +40,7 @@ var (
|
||||
METRIC_RES_TYPE_RDS: 4,
|
||||
METRIC_RES_TYPE_REDIS: 5,
|
||||
METRIC_RES_TYPE_CLOUDACCOUNT: 6,
|
||||
METRIC_RES_TYPE_STORAGE: 7,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -13,12 +13,13 @@ var (
|
||||
}
|
||||
|
||||
MEASUREMENT_TAG_KEYWORD = map[string]string{
|
||||
"host": "host",
|
||||
"guest": "vm_name",
|
||||
"redis": "redis_name",
|
||||
"rds": "rds_name",
|
||||
"oss": "oss_name",
|
||||
"cloudaccount": "cloudaccount_name",
|
||||
METRIC_RES_TYPE_HOST: "host",
|
||||
METRIC_RES_TYPE_GUEST: "vm_name",
|
||||
METRIC_RES_TYPE_REDIS: "redis_name",
|
||||
METRIC_RES_TYPE_RDS: "rds_name",
|
||||
METRIC_RES_TYPE_OSS: "oss_name",
|
||||
METRIC_RES_TYPE_CLOUDACCOUNT: "cloudaccount_name",
|
||||
METRIC_RES_TYPE_STORAGE: "storage_name",
|
||||
}
|
||||
MEASUREMENT_TAG_ID = map[string]string{
|
||||
METRIC_RES_TYPE_HOST: "host_id",
|
||||
@@ -29,6 +30,7 @@ var (
|
||||
METRIC_RES_TYPE_CLOUDACCOUNT: "cloudaccount_id",
|
||||
METRIC_RES_TYPE_TENANT: "tenant_id",
|
||||
METRIC_RES_TYPE_DOMAIN: "domain_id",
|
||||
METRIC_RES_TYPE_STORAGE: "storage_id",
|
||||
}
|
||||
AlertReduceFunc = map[string]string{
|
||||
"avg": "average value",
|
||||
|
||||
@@ -562,6 +562,9 @@ func (c *QueryCondition) getOnecloudResources() ([]jsonutils.JSONObject, error)
|
||||
allResources, err = ListAllResources(&mc_mds.Projects, query)
|
||||
case monitor.METRIC_RES_TYPE_DOMAIN:
|
||||
allResources, err = ListAllResources(&mc_mds.Domains, query)
|
||||
case monitor.METRIC_RES_TYPE_STORAGE:
|
||||
query.Remove("status")
|
||||
allResources, err = ListAllResources(&mc_mds.Storages, query)
|
||||
default:
|
||||
query := jsonutils.NewDict()
|
||||
query.Set("brand", jsonutils.NewString(hostconsts.TELEGRAF_TAG_ONECLOUD_BRAND))
|
||||
@@ -730,6 +733,8 @@ func (c *QueryCondition) getTagKeyRelationMap() map[string]string {
|
||||
relationMap = monitor.TenantTags
|
||||
case monitor.METRIC_RES_TYPE_DOMAIN:
|
||||
relationMap = monitor.DomainTags
|
||||
case monitor.METRIC_RES_TYPE_STORAGE:
|
||||
relationMap = monitor.StorageTags
|
||||
default:
|
||||
relationMap = monitor.HostTags
|
||||
}
|
||||
|
||||
@@ -266,4 +266,9 @@ func init() {
|
||||
newMetricFieldCreateInput("balance", "balance", monitor.METRIC_UNIT_RMB, 1),
|
||||
})
|
||||
|
||||
RegistryMetricCreateInput("storage", "Storage usage",
|
||||
monitor.METRIC_RES_TYPE_STORAGE, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{
|
||||
newMetricFieldCreateInput("usage_active", "Storage utilization rate", monitor.METRIC_UNIT_PERCENT, 1),
|
||||
newMetricFieldCreateInput("free", "Free storage", monitor.METRIC_UNIT_MB, 2),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user