| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- // Copyright 2019 Yunion
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- package monitor
- import (
- "yunion.io/x/pkg/util/sets"
- "yunion.io/x/onecloud/pkg/apis"
- )
- const EXT_PREFIX = "ext"
- const (
- METRIC_RES_TYPE_GUEST = "guest"
- METRIC_RES_TYPE_HOST = "host"
- METRIC_RES_TYPE_REDIS = "redis"
- METRIC_RES_TYPE_OSS = "oss"
- METRIC_RES_TYPE_RDS = "rds"
- METRIC_RES_TYPE_CLOUDACCOUNT = "cloudaccount"
- METRIC_RES_TYPE_AGENT = "agent"
- METRIC_RES_TYPE_TENANT = "tenant"
- METRIC_RES_TYPE_DOMAIN = "domain"
- METRIC_RES_TYPE_STORAGE = "storage"
- METRIC_RES_TYPE_ELB = "elb"
- METRIC_RES_TYPE_K8S = "k8s"
- METRIC_RES_TYPE_CONTAINER = "container"
- METRIC_RES_TYPE_SYSTEM = "system"
- //ext is prefix!
- METRIC_RES_TYPE_JENKINS = "ext_jenkins"
- METRIC_RES_TYPE_EXT_MYSQL = "ext_mysql"
- METRIC_RES_TYPE_EXT_REDIS = "ext_redis"
- METRIC_RES_TYPE_EXT_RABBITMQ = "ext_rabbitmq"
- METRIC_UNIT_PERCENT = "%"
- METRIC_UNIT_BPS = "bps"
- METRIC_UNIT_PPS = "pps"
- METRIC_UNIT_MBPS = "Mbps"
- METRIC_UNIT_BYTEPS = "Bps"
- METRIC_UNIT_CPS = "cps"
- METRIC_UNIT_COUNT = "count"
- METRIC_UNIT_MS = "ms"
- METRIC_UNIT_SEC = "s"
- METRIC_UNIT_BYTE = "byte"
- METRIC_UNIT_MB = "Mb"
- METRIC_UNIT_NULL = "NULL"
- METRIC_DATABASE_TELE = "telegraf"
- METRIC_DATABASE_METER = "meter_db"
- METRIC_DATABASE_SYSTEM = "system"
- )
- var (
- MetricCloudResTypes = sets.NewString(
- METRIC_RES_TYPE_HOST,
- METRIC_RES_TYPE_AGENT,
- METRIC_RES_TYPE_GUEST,
- METRIC_RES_TYPE_CONTAINER,
- METRIC_RES_TYPE_OSS,
- METRIC_RES_TYPE_RDS,
- METRIC_RES_TYPE_REDIS,
- METRIC_RES_TYPE_TENANT,
- METRIC_RES_TYPE_DOMAIN,
- METRIC_RES_TYPE_STORAGE,
- METRIC_RES_TYPE_CLOUDACCOUNT)
- MetricResType = []string{METRIC_RES_TYPE_GUEST, METRIC_RES_TYPE_HOST, METRIC_RES_TYPE_REDIS, METRIC_RES_TYPE_OSS,
- METRIC_RES_TYPE_RDS, METRIC_RES_TYPE_CLOUDACCOUNT}
- MetricUnit = []string{METRIC_UNIT_PERCENT, METRIC_UNIT_BPS, METRIC_UNIT_MBPS, METRIC_UNIT_BYTEPS, "count/s",
- METRIC_UNIT_COUNT, METRIC_UNIT_MS, METRIC_UNIT_BYTE, METRIC_UNIT_NULL}
- ResTypeScoreMap = map[string]float64{
- METRIC_RES_TYPE_HOST: -100,
- METRIC_RES_TYPE_GUEST: -99,
- METRIC_RES_TYPE_AGENT: -98,
- METRIC_RES_TYPE_CONTAINER: -97,
- METRIC_RES_TYPE_SYSTEM: -96,
- METRIC_RES_TYPE_K8S: -95,
- METRIC_RES_TYPE_ELB: -94,
- METRIC_RES_TYPE_CLOUDACCOUNT: -93,
- METRIC_RES_TYPE_STORAGE: -93,
- }
- )
- type MetricMeasurementCreateInput struct {
- apis.StandaloneResourceCreateInput
- apis.EnabledBaseResourceCreateInput
- ResType string `json:"res_type"`
- DisplayName string `json:"display_name"`
- Database string `json:"database"`
- Score int `json:"score"`
- }
- type MetricMeasurementUpdateInput struct {
- apis.StandaloneResourceBaseUpdateInput
- ResType string `json:"res_type"`
- DisplayName string `json:"display_name"`
- }
- type MetricMeasurementListInput struct {
- apis.StatusStandaloneResourceListInput
- apis.EnabledResourceBaseListInput
- apis.ScopedResourceBaseListInput
- ResType string `json:"res_type"`
- DisplayName string `json:"display_name"`
- }
- type MetricFieldCreateInput struct {
- apis.StandaloneResourceCreateInput
- DisplayName string `json:"display_name"`
- Unit string `json:"unit"`
- ValueType string `json:"value_type"`
- Score int `json:"score"`
- }
- type MetricFieldUpdateInput struct {
- apis.StandaloneResourceBaseUpdateInput
- Id string `json:"id"`
- DisplayName string `json:"display_name"`
- Unit string `json:"unit"`
- ValueType string `json:"value_type"`
- Score int `json:"score"`
- }
- type MetricFieldListInput struct {
- apis.StatusStandaloneResourceListInput
- apis.EnabledResourceBaseListInput
- apis.ScopedResourceBaseListInput
- DisplayName string `json:"display_name"`
- Unit string `json:"unit"`
- Scope string `json:"scope"`
- }
- type MetricCreateInput struct {
- Measurement MetricMeasurementCreateInput `json:"measurement"`
- MetricFields []MetricFieldCreateInput `json:"metric_fields"`
- Scope string `json:"scope"`
- }
- type MetricUpdateInput struct {
- apis.Meta
- Measurement MetricMeasurementUpdateInput `json:"measurement"`
- MetricFields []MetricFieldUpdateInput `json:"metric_fields"`
- Scope string `json:"scope"`
- }
- type MetricListInput struct {
- apis.Meta
- Measurement MetricMeasurementListInput `json:"measurement"`
- MetricFields MetricFieldListInput `json:"metric_fields"`
- Scope string `json:"scope"`
- }
- type MetricDetails struct {
- apis.StatusStandaloneResourceDetails
- apis.ScopedResourceBaseInfo
- MetricFields []MetricFieldDetail `json:"metric_fields"`
- }
- type MetricFieldDetail struct {
- Name string `json:"name"`
- DisplayName string `json:"display_name"`
- Unit string `json:"unit"`
- Id string `json:"id"`
- }
- type InfluxMeasurement struct {
- apis.Meta
- Database string `json:"database"`
- Measurement string `json:"measurement"`
- MeasurementDisplayName string `json:"measurement_display_name"`
- ResType string `json:"res_type"`
- Score int `json:"score"`
- TagKey []string `json:"tag_key"`
- TagValue map[string][]string `json:"tag_value"`
- FieldKey []string `json:"field_key"`
- FieldDescriptions map[string]MetricFieldDetail `json:"field_descriptions"`
- Unit []string `json:"unit"`
- }
|