monitor

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALERT_RESOURCE_RECORD_SHIELD_KEY   = "send_state"
	ALERT_RESOURCE_RECORD_SHIELD_VALUE = "hide"
)
View Source
const (
	AlertNotificationUsedByMeterAlert     = "meter_alert"
	AlertNotificationUsedByNodeAlert      = "node_alert"
	AlertNotificationUsedByCommonAlert    = "common_alert"
	AlertNotificationUsedByMigrationAlert = "migration_alert"
)
View Source
const (
	SEND_STATE_OK     = "ok"
	SEND_STATE_SILENT = "silent"
	SEND_STATE_SHIELD = "shield"
)
View Source
const (
	ALERT_STATUS_READY       = "ready"
	ALERT_STATUS_DELETE      = "start_delete"
	ALERT_STATUS_DELETE_FAIL = "delete_fail"
	ALERT_STATUS_DELETING    = "deleting"
	ALERT_STATUS_DELETED     = "deleted"

	CommonAlertSystemAlertType  = "system"
	CommonAlertNomalAlertType   = "normal"
	CommonAlertServiceAlertType = "service"

	MonitorComponentType = "default-monitor"
	MonitorComponentPort = 30093
	SubscribAPI          = "subscriptions"
	MonitorDefaultRC     = "30day_only"
	MonitorSubName       = "commonalert"
	MonitorSubDataBase   = "telegraf"

	CommonAlertDefaultRecipient = "commonalert-default"

	//metirc fields 之间的运算
	CommonAlertFieldOpt_Division = "/"

	DEFAULT_SEND_NOTIFY_CHANNEL = "users"

	METRIC_QUERY_TYPE_NO_DATA     = "nodata_query"
	METRIC_QUERY_NO_DATA_THESHOLD = "nodata"

	CommonAlertLevelNormal    = "normal"
	CommonAlertLevelImportant = "important"
	CommonAlertLevelFatal     = "fatal"
)
View Source
const (
	DataSourceTypeInfluxdb        = apis.SERVICE_TYPE_INFLUXDB
	DataSourceTypeVictoriaMetrics = apis.SERVICE_TYPE_VICTORIA_METRICS
)
View Source
const (
	MeterAlertTypeBalance     = "balance"
	MeterAlertTypeDailyResFee = "resFee"
	MeterAlertTypeMonthResFee = "monthFee"
)
View Source
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"

	//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"
)
View Source
const (
	MigrationAlertMetricTypeCPUUsageActive = "cpu.usage_active"
	MigrationAlertMetricTypeMemAvailable   = "mem.available"
)
View Source
const (
	MONITOR_RESOURCE_ALERT_STATUS_INIT     = "init"
	MONITOR_RESOURCE_ALERT_STATUS_ATTACH   = "attach"
	MONITOR_RESOURCE_ALERT_STATUS_ALERTING = "alerting"
)
View Source
const (
	NodeAlertTypeGuest = "guest"
	NodeAlertTypeHost  = "host"
)
View Source
const (
	ConditionGreaterThan = "gt"
	ConditionLessThan    = "lt"
)
View Source
const (
	AlertNotificationTypeOneCloud      = "onecloud"
	AlertNotificationTypeDingding      = "dingding"
	AlertNotificationTypeFeishu        = "feishu"
	AlertNotificationTypeAutoScaling   = "autoscaling"
	AlertNotificationTypeAutoMigration = "automigration"
)
View Source
const ConditionTypeMetricQuery = "metricquery"
View Source
const EXT_PREFIX = "ext"
View Source
const (
	MigrationAlertResourceTypeHost = "host"
)
View Source
const (
	QUERY_SIGNATURE_KEY = "signature"
)

Variables

View Source
var (
	ErrCannotChangeStateOnPausedAlert = errors.Error("Cannot change state on pause alert")
	ErrRequiresNewState               = errors.Error("update alert state requires a new state")
)
View Source
var (
	UnionTags = []string{
		"host",
		"host_id",
		"id",
		"ips",
		"name",
		"zone",
		"zone_id",
		"zone_ext_id",
		"os_type",
		"status",
		"cloudregion",
		"cloudregion_id",
		"region_ext_id",
		"tenant",
		"tenant_id",
		"brand",
		"vm_scaling_group_id",
		"domain_id",
		"project_domain",
	}

	ServerTags = map[string]string{
		"host":             "host",
		"host_id":          "host_id",
		"vm_id":            "id",
		"vm_ip":            "ips",
		"vm_name":          "name",
		"zone":             "zone",
		"zone_id":          "zone_id",
		"zone_ext_id":      "zone_ext_id",
		"os_type":          "os_type",
		"status":           "status",
		"cloudregion":      "cloudregion",
		"cloudregion_id":   "cloudregion_id",
		"region_ext_id":    "region_ext_id",
		"tenant":           "tenant",
		"tenant_id":        "tenant_id",
		"brand":            "brand",
		"scaling_group_id": "vm_scaling_group_id",
		"domain_id":        "domain_id",
		"project_domain":   "project_domain",
		"account":          "account",
		"account_id":       "account_id",
		"external_id":      "external_id",
		"eip":              "eip",
		"eip_mode":         "eip_mode",
		"ips":              "ips",
		"vips":             "vips",
		"vip":              "vip",
		"vip_eip":          "vip_eip",
	}

	HostTags = map[string]string{
		"host_id":        "id",
		"host_ip":        "ips",
		"host":           "name",
		"zone":           "zone",
		"zone_id":        "zone_id",
		"zone_ext_id":    "zone_ext_id",
		"os_type":        "os_type",
		"status":         "status",
		"cloudregion":    "cloudregion",
		"cloudregion_id": "cloudregion_id",
		"region_ext_id":  "region_ext_id",
		"tenant":         "tenant",
		"tenant_id":      "tenant_id",
		"brand":          "brand",
		"domain_id":      "domain_id",
		"project_domain": "project_domain",
		"access_ip":      "access_ip",
		"account":        "account",
		"account_id":     "account_id",
	}

	RdsTags = map[string]string{
		"host":                    "host",
		"host_id":                 "host_id",
		"rds_id":                  "id",
		"rds_ip":                  "ips",
		"rds_name":                "name",
		"zone":                    "zone",
		"zone_id":                 "zone_id",
		"zone_ext_id":             "zone_ext_id",
		"os_type":                 "os_type",
		"status":                  "status",
		"cloudregion":             "cloudregion",
		"cloudregion_id":          "cloudregion_id",
		"region_ext_id":           "region_ext_id",
		"tenant":                  "tenant",
		"tenant_id":               "tenant_id",
		"brand":                   "brand",
		"domain_id":               "domain_id",
		"project_domain":          "project_domain",
		"external_id":             "external_id",
		"ip_addrs":                "ip_addrs",
		"connection_str":          "connection_str",
		"internal_connection_str": "internal_connection_str",
	}

	RedisTags = map[string]string{
		"host":           "host",
		"host_id":        "host_id",
		"redis_id":       "id",
		"redis_ip":       "ips",
		"redis_name":     "name",
		"zone":           "zone",
		"zone_id":        "zone_id",
		"zone_ext_id":    "zone_ext_id",
		"os_type":        "os_type",
		"status":         "status",
		"cloudregion":    "cloudregion",
		"cloudregion_id": "cloudregion_id",
		"region_ext_id":  "region_ext_id",
		"tenant":         "tenant",
		"tenant_id":      "tenant_id",
		"brand":          "brand",
		"domain_id":      "domain_id",
		"project_domain": "project_domain",
	}

	OssTags = map[string]string{
		"host":           "host",
		"host_id":        "host_id",
		"oss_id":         "id",
		"oss_ip":         "ips",
		"oss_name":       "name",
		"zone":           "zone",
		"zone_id":        "zone_id",
		"zone_ext_id":    "zone_ext_id",
		"os_type":        "os_type",
		"status":         "status",
		"cloudregion":    "cloudregion",
		"cloudregion_id": "cloudregion_id",
		"region_ext_id":  "region_ext_id",
		"tenant":         "tenant",
		"tenant_id":      "tenant_id",
		"brand":          "brand",
		"domain_id":      "domain_id",
		"project_domain": "project_domain",
	}

	ElbTags = map[string]string{
		"host":           "host",
		"host_id":        "host_id",
		"elb_id":         "id",
		"elb_ip":         "ips",
		"elb_name":       "name",
		"zone":           "zone",
		"zone_id":        "zone_id",
		"zone_ext_id":    "zone_ext_id",
		"os_type":        "os_type",
		"status":         "status",
		"region":         "region",
		"cloudregion":    "cloudregion",
		"cloudregion_id": "cloudregion_id",
		"tenant":         "tenant",
		"tenant_id":      "tenant_id",
		"brand":          "brand",
		"domain_id":      "domain_id",
		"project_domain": "project_domain",
	}

	CloudAccountTags = map[string]string{
		"cloudaccount_id":   "id",
		"cloudaccount_name": "name",
		"brand":             "brand",
		"domain_id":         "domain_id",
		"project_domain":    "project_domain",
	}

	TenantTags = map[string]string{
		"tenant_id":      "id",
		"tenant":         "name",
		"domain_id":      "domain_id",
		"project_domain": "project_domain",
	}
	DomainTags = map[string]string{
		"domain_id":      "id",
		"project_domain": "name",
	}

	StorageTags = map[string]string{
		"storage_id":     "id",
		"storage_name":   "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",
	}
)
View Source
var (
	AlertNotificationStatePending   = AlertNotificationStateType("pending")
	AlertNotificationStateCompleted = AlertNotificationStateType("completed")
	AlertNotificationStateUnknown   = AlertNotificationStateType("unknown")
)
View Source
var (
	UNIFIED_MONITOR_FIELD_OPT_TYPE   = []string{"Aggregations", "Selectors"}
	UNIFIED_MONITOR_GROUPBY_OPT_TYPE = []string{"time", "tag", "fill"}
	UNIFIED_MONITOR_FIELD_OPT_VALUE  = map[string][]string{
		"Aggregations": {"MEAN", "SUM"},
		"Selectors":    {"BOTTOM", "FIRST", "LAST", "MAX", "MIN", "TOP"},
	}
	UNIFIED_MONITOR_GROUPBY_OPT_VALUE = map[string][]string{
		"fill": {"linear", "none", "previous", "0"},
	}

	MEASUREMENT_TAG_KEYWORD = map[string]string{
		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",
		METRIC_RES_TYPE_AGENT:        "vm_name",
	}
	MEASUREMENT_TAG_ID = map[string]string{
		METRIC_RES_TYPE_HOST:         "host_id",
		METRIC_RES_TYPE_GUEST:        "vm_id",
		METRIC_RES_TYPE_AGENT:        "vm_id",
		METRIC_RES_TYPE_REDIS:        "redis_id",
		METRIC_RES_TYPE_RDS:          "rds_id",
		METRIC_RES_TYPE_OSS:          "oss_id",
		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",
		"sum":          "Summation",
		"min":          "minimum value",
		"max":          "Maximum",
		"count":        "count value",
		"last":         "Latest value",
		"median":       "median",
		"diff":         "The difference between the latest value and the oldest value. The judgment basis value must be legal",
		"percent_diff": "The difference between the new value and the old value,based on the percentage of the old value",
	}
)
View Source
var ValidateReducerTypes = sets.NewString()

Functions

func DigestQuerySignature

func DigestQuerySignature(data *jsonutils.JSONDict) string

func IsValidMigrationAlertMetricType

func IsValidMigrationAlertMetricType(t MigrationAlertMetricType) error

Types

type AlertCloneDashboardInput

type AlertCloneDashboardInput struct {
	CloneName string `json:"clone_name"`
}

type AlertClonePanelInput

type AlertClonePanelInput struct {
	PanelId        string `json:"panel_id"`
	ClonePanelName string `json:"clone_panel_name"`
}

type AlertCondition

type AlertCondition struct {
	Type      string     `json:"type"`
	Query     AlertQuery `json:"query"`
	Reducer   Condition  `json:"reducer"`
	Evaluator Condition  `json:"evaluator"`
	Operator  string     `json:"operator"`
}

type AlertCreateInput

type AlertCreateInput struct {
	apis.Meta

	// 报警名称
	Name string `json:"name"`
	// 报警执行频率
	Frequency int64 `json:"frequency"`
	// 报警持续时间
	For int64 `json:"for"`
	// 报警设置
	Settings AlertSetting `json:"settings"`
	// 启用报警
	Enabled *bool `json:"enabled"`
	// 报警级别
	Level string `json:"level"`
	// 没有收到监控指标时将当前报警状态设置为对应的状态
	NoDataState string `json:"no_data_state"`
	// 报警执行错误将当前报警状态设置为对应的状态
	ExecutionErrorState string `json:"execution_error_state"`
	UsedBy              string `json:"used_by"`
	// customize info
	CustomizeConfig jsonutils.JSONObject `json:"customize_config"`
}

type AlertDashBoardCreateInput

type AlertDashBoardCreateInput struct {
	apis.Meta
	apis.ScopedResourceCreateInput
	apis.StandaloneResourceCreateInput

	Refresh string `json:"refresh"`
}

type AlertDashBoardDetails

type AlertDashBoardDetails struct {
	AlertDetails
	AlertPanelDetails []AlertPanelDetail `json:"alert_panel_details"`
}

type AlertDashBoardListInput

type AlertDashBoardListInput struct {
	AlertListInput
}

type AlertJointCreateInput

type AlertJointCreateInput struct {
	apis.Meta

	AlertId string `json:"alert_id"`
}

type AlertJointResourceBaseDetails

type AlertJointResourceBaseDetails struct {
	apis.JointResourceBaseDetails
	Alert string `json:"alert"`
}

type AlertListInput

type AlertListInput struct {
	apis.ScopedResourceBaseListInput
	apis.EnabledResourceBaseListInput
	apis.StatusStandaloneResourceListInput
	// 以报警是否启用/禁用过滤列表
	// Enabled *bool `json:"enabled"`
	MonitorResourceId []string `json:"monitor_resource_id"`
}

type AlertNotificationStateType

type AlertNotificationStateType string

type AlertPanelCreateInput

type AlertPanelCreateInput struct {
	apis.ScopedResourceInput
	apis.ProjectizedResourceListInput

	CommonMetricInputQuery
	AlertCreateInput

	Refresh     string `json:"refresh"`
	DashboardId string `json:"dashboard_id"`
}

type AlertPanelDetail

type AlertPanelDetail struct {
	PanelName string `json:"panel_name"`
	PanelId   string `json:"panel_id"`
	Refresh   string `json:"refresh"`
	Setting   jsonutils.JSONObject
	PanelDetails
}

type AlertPanelListInput

type AlertPanelListInput struct {
	AlertListInput
	DashboardId string `json:"dashboard_id"`
}

type AlertPanelUpdateInput

type AlertPanelUpdateInput struct {
	apis.ScopedResourceBaseInfo
	CommonMetricInputQuery
	V1AlertUpdateInput

	Refresh string `json:"refresh"`
}

type AlertPauseInput

type AlertPauseInput struct {
	apis.Meta

	Paused bool `json:"paused"`
}

type AlertQuery

type AlertQuery struct {
	Model MetricQuery `json:"model"`
	From  string      `json:"from"`
	To    string      `json:"to"`
	// 查询结果 reducer,执行 p95 这些操作
	ResultReducer *Condition `json:"result_reducer"`
}

type AlertRecordCreateInput

type AlertRecordCreateInput struct {
	apis.StandaloneResourceCreateInput

	AlertId string `json:"alert_id"`
	// 报警级别
	Level     string             `json:"level"`
	State     string             `json:"state"`
	SendState string             `json:"send_state"`
	ResType   string             `json:"res_type"`
	EvalData  []*EvalMatch       `json:"eval_data"`
	AlertRule []*AlertRecordRule `json:"alert_rule"`
}

type AlertRecordDetails

type AlertRecordDetails struct {
	SAlertRecord

	apis.StatusStandaloneResourceDetails
	apis.ScopedResourceBaseInfo

	ResNum      int64  `json:"res_num"`
	AlertName   string `json:"alert_name"`
	TriggerTime time.Time
}

func (AlertRecordDetails) GetMetricTags

func (self AlertRecordDetails) GetMetricTags() map[string]string

type AlertRecordListInput

type AlertRecordListInput struct {
	apis.Meta

	apis.ScopedResourceBaseListInput
	apis.EnabledResourceBaseListInput
	apis.StatusStandaloneResourceListInput

	AlertId  string `json:"alert_id"`
	Level    string `json:"level"`
	State    string `json:"state"`
	ResType  string `json:"res_type"`
	Alerting bool   `json:"alerting"`
	ResName  string `json:"res_name"`
}

type AlertRecordRule

type AlertRecordRule struct {
	Metric          string `json:"metric"`
	Database        string `json:"database"`
	Measurement     string `json:"measurement"`
	MeasurementDesc string `json:"measurement_desc"`
	ResType         string `json:"res_type"`
	Field           string `json:"field"`
	FieldDesc       string `json:"field_desc"`
	// 比较运算符, 比如: >, <, >=, <=
	Comparator string `json:"comparator"`
	// 报警阀值
	Threshold     string `json:"threshold"`
	Period        string `json:"period"`
	AlertDuration int64  `json:"alert_duration"`
	ConditionType string `json:"condition_type"`
	// 静默期
	SilentPeriod string `json:"silent_period"`
	Reducer      string `json:"reducer"`
}

type AlertRecordShieldCreateInput

type AlertRecordShieldCreateInput struct {
	apis.StandaloneResourceCreateInput

	AlertId string `json:"alert_id"`
	ResType string `json:"res_type"`
	ResName string `json:"res_name"`
	ResId   string `json:"res_id"`

	StartTime string `json:"start_time"`
	EndTime   string `json:"end_time"`
}

type AlertRecordShieldDetails

type AlertRecordShieldDetails struct {
	apis.StatusStandaloneResourceDetails
	apis.ScopedResourceBaseInfo

	CommonAlertDetails
	AlertName string `json:"alert_name"`
	ResName   string `json:"res_name"`
	Expired   bool   `json:"expired"`
}

type AlertRecordShieldListInput

type AlertRecordShieldListInput struct {
	apis.Meta

	apis.ScopedResourceBaseListInput
	apis.EnabledResourceBaseListInput
	apis.StatusStandaloneResourceListInput

	AlertName string     `json:"alert_name"`
	ResType   string     `json:"res_type"`
	ResName   string     `json:"res_name"`
	ResId     string     `json:"res_id"`
	AlertId   string     `json:"alert_id"`
	StartTime *time.Time `json:"start_time"`
	EndTime   *time.Time `json:"end_time"`
}

type AlertResourceAlertDetails

type AlertResourceAlertDetails struct {
	AlertResourceJointBaseDetails
	Alert                    string                      `json:"alert"`
	AlertType                string                      `json:"alert_type"`
	Level                    string                      `json:"level"`
	CommonAlertMetricDetails []*CommonAlertMetricDetails `json:"common_alert_metric_details"`
}

type AlertResourceAlertListInput

type AlertResourceAlertListInput struct {
	apis.JointResourceBaseListInput
	AlertResourceId string `json:"alert_resource_id"`
	AlertId         string `json:"alert_id"`
}

type AlertResourceAttachInput

type AlertResourceAttachInput struct {
	apis.Meta

	AlertResourceId string    `json:"alert_resource_id"`
	AlertId         string    `json:"alert_id"`
	AlertRecordId   string    `json:"alert_record_id"`
	Data            EvalMatch `json:"data"`
}

type AlertResourceCreateInput

type AlertResourceCreateInput struct {
	apis.StandaloneResourceCreateInput

	Type AlertResourceType `json:"type"`
}

type AlertResourceDetails

type AlertResourceDetails struct {
	apis.StandaloneResourceDetails
	Count int               `json:"count"`
	Tags  map[string]string `json:"tags"`
}

type AlertResourceJointBaseDetails

type AlertResourceJointBaseDetails struct {
	apis.JointResourceBaseDetails

	AlertResource string            `json:"alert_resource"`
	Type          AlertResourceType `json:"type"`
}

type AlertResourceListInput

type AlertResourceListInput struct {
	apis.StandaloneResourceListInput
	Type string `json:"type"`
}

type AlertResourceRecordCreateInput

type AlertResourceRecordCreateInput struct {
	apis.Meta
	apis.SStandaloneResourceBase

	EvalData      EvalMatch
	AlertTime     time.Time
	ResName       string
	ResType       string
	Brand         string
	TriggerVal    string
	AlertRecordId string
	AlertId       string
	SendState     string
}

type AlertResourceRecordDetails

type AlertResourceRecordDetails struct {
	apis.StatusStandaloneResourceDetails
	apis.ScopedResourceBaseInfo

	AlertName string `json:"alert_name"`
	AlertRule jsonutils.JSONObject
	ResType   string
	Level     string
	State     string
}

type AlertResourceType

type AlertResourceType string
const (
	// AlertResourceTypeNode means onecloud system infrastructure controller or host node
	AlertResourceTypeNode AlertResourceType = "host"
	// AlertResourceTypeCloudaccount means cloudaccount resource
	AlertResourceTypeCloudaccount AlertResourceType = "cloudaccount"
	// AlertResourceTypeVM means virtual machine guest resource
	AlertResourceTypeVM AlertResourceType = "vm"
)

type AlertSetting

type AlertSetting struct {
	Conditions []AlertCondition `json:"conditions"`
}

AlertSettings contains alert conditions

type AlertSeverityType

type AlertSeverityType string

type AlertStateType

type AlertStateType string
const (
	AlertStateNoData   AlertStateType = "no_data"
	AlertStatePaused   AlertStateType = "paused"
	AlertStateAlerting AlertStateType = "alerting"
	AlertStateOK       AlertStateType = "ok"
	AlertStatePending  AlertStateType = "pending"
	AlertStateUnknown  AlertStateType = "unknown"
)

func (AlertStateType) IsValid

func (s AlertStateType) IsValid() bool

type AlertTestRunInput

type AlertTestRunInput struct {
	apis.Meta

	IsDebug bool `json:"is_debug"`
}

type AlertTestRunOutput

type AlertTestRunOutput struct {
	apis.Meta

	Firing             bool              `json:"firing"`
	IsTestRun          bool              `json:"is_test_run"`
	IsDebug            bool              `json:"is_debug"`
	EvalMatches        []*EvalMatch      `json:"eval_matches"`
	AlertOKEvalMatches []*EvalMatch      `json:"alert_ok_eval_matches"`
	Logs               []*ResultLogEntry `json:"logs"`
	Error              error             `json:"error"`
	ConditionEvals     string            `json:"condition_evals"`
	StartTime          time.Time         `json:"start_time"`
	EndTime            time.Time         `json:"end_time"`
	NoDataFound        bool              `json:"no_data_found"`
	PrevAlertState     string            `json:"prev_alert_state"`
}

type AlertUpdateInput

type AlertUpdateInput struct {
	apis.StandaloneResourceBaseUpdateInput

	Message *string `json:"message"`

	// 报警执行频率
	Frequency *int64 `json:"frequency"`
	// 报警持续时间
	For int64 `json:"for"`
	// 报警设置
	Settings *AlertSetting `json:"settings"`
	// 启用报警
	Enabled *bool `json:"enabled"`
	// 报警级别
	Level *string `json:"level"`
	// 没有收到监控指标时将当前报警状态设置为对应的状态
	NoDataState string `json:"no_data_state"`
	// 报警执行错误将当前报警状态设置为对应的状态
	ExecutionErrorState string `json:"execution_error_state"`
}

type AlertV1Details

type AlertV1Details struct {
	AlertDetails

	Name        string  `json:"name"`
	Period      string  `json:"period"`
	Window      string  `json:"window"`
	Comparator  string  `json:"comparator"`
	Threshold   float64 `json:"threshold"`
	Recipients  string  `json:"recipients"`
	Level       string  `json:"level"`
	Channel     string  `json:"channel"`
	DB          string  `json:"db"`
	Measurement string  `json:"measurement"`
	Field       string  `json:"field"`
	NotifierId  string  `json:"notifier_id"`
	Status      string  `json:"status"`
}

type AlertnotificationCreateInput

type AlertnotificationCreateInput struct {
	AlertJointCreateInput

	NotificationId string               `json:"notification_id"`
	UsedBy         string               `json:"used_by"`
	Params         jsonutils.JSONObject `json:"params"`
}

type AlertnotificationDetails

type AlertnotificationDetails struct {
	AlertJointResourceBaseDetails
	Notification string `json:"notification"`
}

type CommonAlertCreateBaseInput

type CommonAlertCreateBaseInput struct {
	// 报警连续持续周期数
	AlertDuration int64 `json:"alert_duration"`
	// 通知方式, 比如: email, mobile
	Channel []string `json:"channel"`
	// 通知接受者
	Recipients []string `json:"recipients"`

	RobotIds []string `json:"robot_ids"`

	// 角色 id 或者 name
	Roles []string `json:"roles"`

	// 静默期
	SilentPeriod string `json:"silent_period"`
	// 报警类型
	AlertType string `json:"alert_type"`

	// Scope Resource
	Scope       string `json:"scope"`
	DomainId    string `json:"domain_id"`
	ProjectId   string `json:"project_id"`
	GetPointStr bool   `json:"get_point_str"`
	MetaName    string `json:"meta_name"`
	Description string `json:"description"`
}

type CommonAlertCreateInput

type CommonAlertCreateInput struct {
	CommonMetricInputQuery
	AlertCreateInput
	CommonAlertCreateBaseInput

	// 查询指标周期
	Period string `json:"period"`
}

type CommonAlertDetails

type CommonAlertDetails struct {
	AlertDetails
	Period string `json:"period"`
	// 报警连续持续周期数
	AlertDuration int64    `json:"alert_duration"`
	Level         string   `json:"level"`
	NotifierId    string   `json:"notifier_id"`
	Channel       []string `json:"channel"`
	Recipients    []string `json:"recipients"`
	RobotIds      []string `json:"robot_ids"`
	RoleIds       []string `json:"role_ids"`
	// 静默期
	SilentPeriod string `json:"silent_period"`
	Status       string `json:"status"`
	// 报警类型
	AlertType                string                      `json:"alert_type"`
	CommonAlertMetricDetails []*CommonAlertMetricDetails `json:"common_alert_metric_details"`
}

type CommonAlertListInput

type CommonAlertListInput struct {
	AlertListInput
	//V1AlertListInput
	// 报警类型
	AlertType string `json:"alert_type"`
	// 监控指标名称
	Metric string `json:"metric"`

	Level   string   `json:"level"`
	ResType []string `json:"res_type"`
	UsedBy  string   `json:"used_by"`
	Name    string   `json:"name"`
}

type CommonAlertMetricDetails

type CommonAlertMetricDetails struct {
	Operator      string    `json:"operator"`
	Comparator    string    `json:"comparator"`
	Threshold     float64   `json:"threshold"`
	WithinRange   []float64 `json:"within_range"`
	ConditionType string    `json:"condition_type"`
	ThresholdStr  string    `json:"threshold_str"`
	// metric points'value的运算方式
	Reduce                 string           `json:"reduce"`
	DB                     string           `json:"db"`
	Measurement            string           `json:"measurement"`
	MeasurementDisplayName string           `json:"measurement_display_name"`
	ResType                string           `json:"res_type"`
	Field                  string           `json:"field"`
	Groupby                string           `json:"groupby"`
	Filters                []MetricQueryTag `json:"filters"`
	FieldDescription       MetricFieldDetail
	FieldOpt               string `json:"field_opt"`
	GetPointStr            bool   `json:"get_point_str"`
}

type CommonAlertQuery

type CommonAlertQuery struct {
	*AlertQuery
	// metric points'value的运算方式
	Reduce string `json:"reduce"`
	// 比较运算符, 比如: >, <, >=, <=
	Comparator string `json:"comparator"`
	// 报警阀值
	Threshold float64 `json:"threshold"`
	//field yunsuan
	FieldOpt      string `json:"field_opt"`
	ConditionType string `json:"condition_type"`
	// Operator should be chosen from 'and | or'
	Operator string `json:"operator"`
}

type CommonAlertUpdateInput

type CommonAlertUpdateInput struct {
	CommonMetricInputQuery
	V1AlertUpdateInput

	// 查询指标周期
	Period string `json:"period"`
	// 报警连续持续周期数
	AlertDuration int64 `json:"alert_duration"`
	// 通知方式, 比如: email, mobile
	Channel []string `json:"channel"`
	// 通知接受者
	Recipients []string `json:"recipients"`
	// 静默期
	SilentPeriod string `json:"silent_period"`
	// systemalert policy may need update through operator
	ForceUpdate bool   `json:"force_update"`
	GetPointStr bool   `json:"get_point_str"`
	MetaName    string `json:"meta_name"`
}

type CommonMetricInputQuery

type CommonMetricInputQuery struct {
	From        string              `json:"from"`
	To          string              `json:"to"`
	Interval    string              `json:"interval"`
	MetricQuery []*CommonAlertQuery `json:"metric_query"`
}

type Condition

type Condition struct {
	Type      string    `json:"type"`
	Params    []float64 `json:"params"`
	Operators []string  `json:"operators"`
}

func GetNodeAlertEvaluator

func GetNodeAlertEvaluator(comparator string, threshold float64) Condition

type EvalMatch

type EvalMatch struct {
	Condition    string               `json:"condition"`
	Value        *float64             `json:"value"`
	ValueStr     string               `json:"value_str"`
	Metric       string               `json:"metric"`
	Tags         map[string]string    `json:"tags"`
	Unit         string               `json:"unit"`
	AlertDetails jsonutils.JSONObject `json:"alert_details"`
}

EvalMatch represents the series violating the threshold.

type ExecutionErrorOption

type ExecutionErrorOption string
const (
	ExecutionErrorSetAlerting ExecutionErrorOption = "alerting"
	ExecutionErrorKeepState   ExecutionErrorOption = "keep_state"
)

func (ExecutionErrorOption) IsValid

func (s ExecutionErrorOption) IsValid() bool

func (ExecutionErrorOption) ToAlertState

func (s ExecutionErrorOption) ToAlertState() AlertStateType

type IMigrationAlertMetric

type IMigrationAlertMetric interface {
	GetType() MigrationAlertMetricType
	GetQueryFields() *MetricQueryFields
}

type InfluxMeasurement

type InfluxMeasurement struct {
	apis.Meta
	Database               string
	Measurement            string
	MeasurementDisplayName string
	ResType                string
	Score                  int
	TagKey                 []string
	TagValue               map[string][]string
	FieldKey               []string
	FieldDescriptions      map[string]MetricFieldDetail
	Unit                   []string
}

type MeterAlertCreateInput

type MeterAlertCreateInput struct {
	ResourceAlertV1CreateInput

	// 监控资源类型, 比如: balance, resFree, monthFee
	Type string `json:"type"`
	// 云平台类型
	Provider string `json:"provider"`
	// 云账号 Id
	AccountId string `json:"account_id"`
	// 项目 Id string
	ProjectId string `json:"project_id"`
}

type MeterAlertDetails

type MeterAlertDetails struct {
	AlertV1Details

	Type      string `json:"type"`
	ProjectId string `json:"project_id"`
	AccountId string `json:"account_id"`
	Provider  string `json:"provider"`
}

type MeterAlertListInput

type MeterAlertListInput struct {
	V1AlertListInput

	// 监控资源类型, 比如: balance, resFree, monthFee
	Type string `json:"type"`
	// 云平台类型
	Provider string `json:"provider"`
	// 云账号 Id
	AccountId string `json:"account_id"`
	// 项目 Id
	ProjectId string `json:"project_id"`
}

type MeterAlertUpdateInput

type MeterAlertUpdateInput struct {
	V1AlertUpdateInput

	// 比较运算符, 比如: >, <, >=, <=
	Comparator *string `json:"comparator"`
	// 报警阀值
	Threshold *float64 `json:"threshold"`
	// 通知接受者
	Recipients *string `json:"recipients"`
	// 项目 Id
	ProjectId *string `json:"project_id"`
	// 通知方式, 比如: email, mobile
	Channel *string `json:"channel"`
	Status  *string `json:"status"`
}

type MeterCustomizeConfig

type MeterCustomizeConfig struct {
	UnitDesc string
	Name     string
	Currency string
}

type MetricCreateInput

type MetricCreateInput struct {
	Measurement  MetricMeasurementCreateInput `json:"measurement"`
	MetricFields []MetricFieldCreateInput     `json:"metric_fields"`
	Scope        string                       `json:"scope"`
}

type MetricDetails

type MetricDetails struct {
	apis.StatusStandaloneResourceDetails
	apis.ScopedResourceBaseInfo

	MetricFields []MetricFieldDetail `json:"metric_fields"`
}

type MetricFieldCreateInput

type MetricFieldCreateInput struct {
	apis.StandaloneResourceCreateInput

	DisplayName string `json:"display_name"`
	Unit        string `json:"unit"`
	ValueType   string `json:"value_type"`
	Score       int    `json:"score"`
}

type MetricFieldDetail

type MetricFieldDetail struct {
	Name        string `json:"name"`
	DisplayName string `json:"display_name"`
	Unit        string `json:"unit"`
	Id          string `json:"id"`
}

type MetricFieldListInput

type MetricFieldListInput struct {
	apis.StatusStandaloneResourceListInput
	apis.EnabledResourceBaseListInput
	apis.ScopedResourceBaseListInput

	DisplayName string `json:"display_name"`
	Unit        string `json:"unit"`
	Scope       string `json:"scope"`
}

type MetricFieldUpdateInput

type MetricFieldUpdateInput struct {
	apis.StandaloneResourceBaseUpdateInput

	Id          string
	DisplayName string `json:"display_name"`
	Unit        string `json:"unit"`
	ValueType   string `json:"value_type"`
	Score       int    `json:"score"`
}

type MetricFunc

type MetricFunc struct {
	FieldOptType  []string            `json:"field_opt_type"`
	FieldOptValue map[string][]string `json:"field_opt_value"`
	GroupOptType  []string            `json:"group_opt_type"`
	GroupOptValue map[string][]string `json:"group_opt_value"`
}

type MetricListInput

type MetricListInput struct {
	apis.Meta

	Measurement  MetricMeasurementListInput `json:"measurement"`
	MetricFields MetricFieldListInput       `json:"metric_fields"`
	Scope        string                     `json:"scope"`
}

type MetricMeasurementCreateInput

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 MetricMeasurementListInput

type MetricMeasurementListInput struct {
	apis.StatusStandaloneResourceListInput
	apis.EnabledResourceBaseListInput
	apis.ScopedResourceBaseListInput

	ResType     string `json:"res_type"`
	DisplayName string `json:"display_name"`
}

type MetricMeasurementUpdateInput

type MetricMeasurementUpdateInput struct {
	apis.StandaloneResourceBaseUpdateInput

	ResType     string `json:"res_type"`
	DisplayName string `json:"display_name"`
}

type MetricQuery

type MetricQuery struct {
	Alias        string              `json:"alias"`
	Tz           string              `json:"tz"`
	Database     string              `json:"database"`
	Measurement  string              `json:"measurement"`
	Tags         []MetricQueryTag    `json:"tags"`
	GroupBy      []MetricQueryPart   `json:"group_by"`
	Selects      []MetricQuerySelect `json:"select"`
	Interval     string              `json:"interval"`
	Policy       string              `json:"policy"`
	ResultFormat string              `json:"result_format"`
}

func GetNodeAlertQuery

func GetNodeAlertQuery(typ, field, measurement, db, nodeId string) MetricQuery

type MetricQueryFields

type MetricQueryFields struct {
	ResourceType MigrationAlertResourceType
	Database     string
	Measurement  string
	Field        string
	Comparator   string
}

type MetricQueryInput

type MetricQueryInput struct {
	From            string        `json:"from"`
	To              string        `json:"to"`
	Scope           string        `json:"scope"`
	Slimit          string        `json:"slimit"`
	Soffset         string        `json:"soffset"`
	Unit            bool          `json:"unit"`
	Interval        string        `json:"interval"`
	DomainId        string        `json:"domain_id"`
	ProjectId       string        `json:"project_id"`
	MetricQuery     []*AlertQuery `json:"metric_query"`
	Signature       string        `json:"signature"`
	ShowMeta        bool          `json:"show_meta"`
	SkipCheckSeries bool          `json:"skip_check_series"`
}

type MetricQueryPart

type MetricQueryPart struct {
	Type   string   `json:"type"`
	Params []string `json:"params"`
}

func NewMetricQueryPartAS

func NewMetricQueryPartAS(alias string) MetricQueryPart

func NewMetricQueryPartCount

func NewMetricQueryPartCount() MetricQueryPart

func NewMetricQueryPartDistinct

func NewMetricQueryPartDistinct() MetricQueryPart

func NewMetricQueryPartField

func NewMetricQueryPartField(fieldName string) MetricQueryPart

func NewMetricQueryPartFunc

func NewMetricQueryPartFunc(funcName string) MetricQueryPart

func NewMetricQueryPartLast

func NewMetricQueryPartLast() MetricQueryPart

func NewMetricQueryPartMath

func NewMetricQueryPartMath(op string, val string) MetricQueryPart

func NewMetricQueryPartMax

func NewMetricQueryPartMax() MetricQueryPart

func NewMetricQueryPartMean

func NewMetricQueryPartMean() MetricQueryPart

func NewMetricQueryPartMin

func NewMetricQueryPartMin() MetricQueryPart

func NewMetricQueryPartSum

func NewMetricQueryPartSum() MetricQueryPart

type MetricQuerySelect

type MetricQuerySelect []MetricQueryPart

func NewMetricQuerySelect

func NewMetricQuerySelect(parts ...MetricQueryPart) MetricQuerySelect

type MetricQueryTag

type MetricQueryTag struct {
	Key       string `json:"key"`
	Operator  string `json:"operator"`
	Value     string `json:"value"`
	Condition string `json:"condition"`
}

type MetricUpdateInput

type MetricUpdateInput struct {
	apis.Meta

	Measurement  MetricMeasurementUpdateInput `json:"measurement"`
	MetricFields []MetricFieldUpdateInput     `json:"metric_fields"`
	Scope        string                       `json:"scope"`
}

type MetricsQueryResult

type MetricsQueryResult struct {
	SeriesTotal   int64
	Series        TimeSeriesSlice
	Metas         []QueryResultMeta
	ReducedResult *ReducedResult
}

type MigrationAlertCreateInput

type MigrationAlertCreateInput struct {
	AlertCreateInput
	// Threshold is the value to trigger migration
	Threshold float64 `json:"threshold"`
	// Period of querying metrics
	Period string `json:"period"`
	// MetricType is supported metric type by auto migration
	MetricType MigrationAlertMetricType `json:"metric_type"`
	// MigrationAlertSettings contain migration configuration
	MigrationSettings *MigrationAlertSettings `json:"migration_settings"`
}

func (MigrationAlertCreateInput) GetEvaluator

func (MigrationAlertCreateInput) GetMetricDriver

func (MigrationAlertCreateInput) ToAlertCreateInput

func (m MigrationAlertCreateInput) ToAlertCreateInput() *AlertCreateInput

type MigrationAlertListInput

type MigrationAlertListInput struct {
	AlertListInput

	MetricType string `json:"metric_type"`
}

type MigrationAlertMetricType

type MigrationAlertMetricType string

type MigrationAlertResourceType

type MigrationAlertResourceType string

type MigrationAlertSettings

type MigrationAlertSettings struct {
	Source *MigrationAlertSettingsSource `json:"source"`
	Target *MigrationAlertSettingsTarget `json:"target"`
}

type MigrationAlertSettingsSource

type MigrationAlertSettingsSource struct {
	GuestIds []string `json:"guest_ids"`
	HostIds  []string `json:"host_ids"`
}

type MigrationAlertSettingsTarget

type MigrationAlertSettingsTarget struct {
	HostIds []string `json:"host_ids"`
}

type MigrationMetricDrivers

type MigrationMetricDrivers struct {
	*sync.Map
}

func GetMigrationAlertMetricDrivers

func GetMigrationAlertMetricDrivers() *MigrationMetricDrivers

func (*MigrationMetricDrivers) Get

type MonitorResourceCreateInput

type MonitorResourceCreateInput struct {
	apis.VirtualResourceCreateInput
	apis.EnabledBaseResourceCreateInput

	ResId       string `json:"res_id"`
	ResType     string `json:"res_type"`
	AlertStatus string `json:"alert_status"`
}

type MonitorResourceDetails

type MonitorResourceDetails struct {
	apis.VirtualResourceDetails
	compute.CloudregionResourceInfo
	compute.CloudaccountResourceInfo
	Ips      string `json:"ips"`
	AccessIp string `json:"access_ip"`

	AttachAlertCount int64  `json:"attach_alert_count"`
	Hypervisor       string `json:"hypervisor"`
}

type MonitorResourceJointCreateInput

type MonitorResourceJointCreateInput struct {
	apis.Meta
	MonitorResourceId string `json:"monitor_resource_id"`
	AlertId           string `json:"alert_id"`
	Metric            string `json:"metric"`

	AlertRecordId string    `width:"36" charset:"ascii" list:"user"  update:"user"`
	AlertState    string    `width:"18" charset:"ascii" list:"user"  update:"user"`
	TriggerTime   time.Time `list:"user"  update:"user" json:"trigger_time"`
	Data          EvalMatch `json:"data"`
}

type MonitorResourceJointDetails

type MonitorResourceJointDetails struct {
	ResName     string               `json:"res_name"`
	ResId       string               `json:"res_id"`
	ResType     string               `json:"res_type"`
	AlertName   string               `json:"alert_name"`
	AlertRule   jsonutils.JSONObject `json:"alert_rule"`
	Level       string               `json:"level"`
	SendState   string               `json:"send_state"`
	State       string               `json:"state"`
	IsSetShield bool                 `json:"is_set_shield"`
}

type MonitorResourceJointListInput

type MonitorResourceJointListInput struct {
	apis.JointResourceBaseListInput
	apis.VirtualResourceListInput
	MonitorResourceId string  `json:"monitor_resource_id"`
	AlertId           string  `json:"alert_id"`
	JointId           []int64 `json:"joint_id"`
	Alerting          bool    `json:"alerting"`
	AlertState        string  `json:"alert_state"`
	SendState         string  `json:"send_state"`
	ResType           string  `json:"res_type"`
	Metric            string  `json:"metric"`
	ResName           string  `json:"res_name"`
	AlertName         string  `json:"alert_name"`
	Level             string  `json:"level"`
	// 查询所有状态
	AllState bool `json:"all_state"`
}

type MonitorResourceListInput

type MonitorResourceListInput struct {
	apis.VirtualResourceListInput
	apis.EnabledResourceBaseListInput
	compute.ManagedResourceListInput

	ResId     []string `json:"res_id"`
	ResType   string   `json:"res_type"`
	OnlyResId bool     `json:"only_res_id"`

	ResName string `json:"res_name"`
}

type NoDataOption

type NoDataOption string
const (
	NoDataSetOK       NoDataOption = "ok"
	NoDataSetNoData   NoDataOption = "no_data"
	NoDataKeepState   NoDataOption = "keep_state"
	NoDataSetAlerting NoDataOption = "alerting"
)

func (NoDataOption) IsValid

func (s NoDataOption) IsValid() bool

func (NoDataOption) ToAlertState

func (s NoDataOption) ToAlertState() AlertStateType

type NodeAlertCreateInput

type NodeAlertCreateInput struct {
	ResourceAlertV1CreateInput

	// 监控指标名称
	Metric string `json:"metric"`
	// 监控资源类型, 比如: guest, host
	Type string `json:"type"`
	// 监控资源名称
	NodeName string `json:"node_name"`
	// 监控资源 Id
	NodeId string `json:"node_id"`

	// CommonAlertCreateInput injected by server and do not pass it through API
	CommonAlertCreateInput *CommonAlertCreateInput `json:"common_alert_create_input,omitempty"`
}

func (NodeAlertCreateInput) GetEvaluator

func (input NodeAlertCreateInput) GetEvaluator() Condition

func (NodeAlertCreateInput) GetQuery

func (input NodeAlertCreateInput) GetQuery(field, measurement, db string) MetricQuery

func (NodeAlertCreateInput) ToCommonAlertCreateInput

func (input NodeAlertCreateInput) ToCommonAlertCreateInput(
	name string,
	field string,
	measurement string,
	db string) CommonAlertCreateInput

type NodeAlertDetails

type NodeAlertDetails struct {
	AlertV1Details

	Type     string `json:"type"`
	Metric   string `json:"metric"`
	NodeId   string `json:"node_id"`
	NodeName string `json:"node_name"`
}

type NodeAlertListInput

type NodeAlertListInput struct {
	AlertListInput

	// 监控指标名称
	Metric string `json:"metric"`
	// 监控资源类型, 比如: guest, host
	Type string `json:"type"`
	// 监控资源名称
	NodeName string `json:"node_name"`
	// 监控资源 Id
	NodeId string `json:"node_id"`
}

func (NodeAlertListInput) ToCommonAlertListInput

func (o NodeAlertListInput) ToCommonAlertListInput() CommonAlertListInput

type NodeAlertUpdateInput

type NodeAlertUpdateInput struct {
	AlertUpdateInput

	// 监控指标名称
	Metric *string `json:"metric"`
	// 监控资源类型, 比如: guest, host
	Type *string `json:"type"`
	// 监控资源名称
	NodeName *string `json:"node_name"`
	// 监控资源 Id
	NodeId *string `json:"node_id"`
	// 查询指标周期
	Period *string `json:"period"`
	// 每隔多久查询一次
	Window *string `json:"window"`
	// 比较运算符, 比如: >, <, >=, <=
	Comparator *string `json:"comparator"`
	// 报警阀值
	Threshold *float64 `json:"threshold"`
	// 报警级别
	Level *string `json:"level"`
	// 通知方式, 比如: email, mobile
	Channel *string `json:"channel"`
	// 通知接受者
	Recipients *string `json:"recipients"`
}

type NotificationCreateInput

type NotificationCreateInput struct {
	apis.Meta

	// 报警通知名称
	Name string `json:"name"`
	// 类型
	Type string `json:"type"`
	// 是否为默认通知配置
	IsDefault bool `json:"is_default"`
	// 是否一直提醒
	SendReminder *bool `json:"send_reminder"`
	// 是否禁用报警恢复提醒
	DisableResolveMessage *bool `json:"disable_resolve_message"`
	// 发送频率 单位:s
	Frequency time.Duration `json:"frequency"`
	// 通知配置
	Settings jsonutils.JSONObject `json:"settings"`
}

type NotificationListInput

type NotificationListInput struct {
	apis.VirtualResourceListInput
	// 类型
	Type string `json:"type"`
}

type NotificationSettingAutoMigration

type NotificationSettingAutoMigration struct {
	AlertId string `json:"alert_id"`
}

type NotificationSettingDingding

type NotificationSettingDingding struct {
	Url         string `json:"url"`
	MessageType string `json:"message_type"`
}

type NotificationSettingFeishu

type NotificationSettingFeishu struct {
	// Url         string `json:"url"`
	AppId     string `json:"app_id"`
	AppSecret string `json:"app_secret"`
}

type NotificationSettingOneCloud

type NotificationSettingOneCloud struct {
	Channel  string   `json:"channel"`
	UserIds  []string `json:"user_ids"`
	RobotIds []string `json:"robot_ids"`
	RoleIds  []string `json:"role_ids"`
}

type NotificationTemplateConfig

type NotificationTemplateConfig struct {
	Title        string      `json:"title"`
	Name         string      `json:"name"`
	ResourceName string      `json:"resource_name"`
	Matches      []EvalMatch `json:"matches"`
	// PrevAlertState AlertStateType `json:"prev_alert_state"`
	// State AlertStateType `json:"state"`
	NoDataFound bool   `json:"no_data"`
	StartTime   string `json:"start_time"`
	EndTime     string `json:"end_time"`
	Description string `json:"description"`
	Priority    string `json:"priority"`
	Level       string `json:"level"`
	IsRecovery  bool   `json:"is_recovery"`
	WebUrl      string `json:"web_url"`
}

type NotificationTemplateCreateInput

type NotificationTemplateCreateInput struct {
	Content string `json:"content"`
}

type NotificationUpdateInput

type NotificationUpdateInput struct {
	apis.Meta

	// 报警通知名称
	Name string `json:"name"`
	// 是否为默认通知配置
	IsDefault *bool `json:"is_default"`
	// 是否一直提醒
	SendReminder *bool `json:"send_reminder"`
	// 是否禁用报警恢复提醒
	DisableResolveMessage *bool `json:"disable_resolve_message"`
	// 发送频率
	Frequency *time.Duration `json:"frequency"`
}

type PanelDetails

type PanelDetails struct {
	AlertDetails
	CommonAlertMetricDetails []*CommonAlertMetricDetails `json:"common_alert_metric_details"`
}

type QueryResultMeta

type QueryResultMeta struct {
	RawQuery           string  `json:"raw_query"`
	ResultReducerValue float64 `json:"result_reducer_value"`
}

type ReducedResult

type ReducedResult struct {
	Reducer Condition `json:"reducer"`
	Result  []float64 `json:"result"`
}

type ReducerType

type ReducerType string
const (
	REDUCER_AVG            ReducerType = "avg"
	REDUCER_SUM            ReducerType = "sum"
	REDUCER_MIN            ReducerType = "min"
	REDUCER_MAX            ReducerType = "max"
	REDUCER_COUNT          ReducerType = "count"
	REDUCER_LAST           ReducerType = "last"
	REDUCER_MEDIAN         ReducerType = "median"
	REDUCER_DIFF           ReducerType = "diff"
	REDUCER_PERCENT_DIFF   ReducerType = "percent_diff"
	REDUCER_COUNT_NON_NULL ReducerType = "count_non_null"
	REDUCER_PERCENTILE     ReducerType = "percentile"
)

type ResourceAlertV1CreateInput

type ResourceAlertV1CreateInput struct {
	AlertCreateInput

	// 查询指标周期
	Period string `json:"period"`
	// 每隔多久查询一次
	Window string `json:"window"`
	// 比较运算符, 比如: >, <, >=, <=
	Comparator string `json:"comparator"`
	// 报警阀值
	Threshold float64 `json:"threshold"`
	// 通知方式, 比如: email, mobile
	Channel string `json:"channel"`
	// 通知接受者
	Recipients string `json:"recipients"`
}

type ResultLogEntry

type ResultLogEntry struct {
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

ResultLogEntry represents log data for the alert evaluation.

type SAlert

type SAlert struct {
	// db.SVirtualResourceBase
	apis.SEnabledResourceBase
	apis.SStatusStandaloneResourceBase
	SMonitorScopedResource
	// Frequency is evaluate period
	Frequency int64                `json:"frequency"`
	Settings  jsonutils.JSONObject `json:"settings"`
	Level     string               `json:"level"`
	Message   string               `json:"message"`
	UsedBy    string               `json:"used_by"`
	// Silenced       bool
	ExecutionError string `json:"execution_error"`
	// If an alert rule has a configured `For` and the query violates the configured threshold
	// it will first go from `OK` to `Pending`. Going from `OK` to `Pending` will not send any
	// notifications. Once the alert rule has been firing for more than `For` duration, it will
	// change to `Alerting` and send alert notifications.
	For                 int64                `json:"for"`
	EvalData            jsonutils.JSONObject `json:"eval_data"`
	State               string               `json:"state"`
	NoDataState         string               `json:"no_data_state"`
	ExecutionErrorState string               `json:"execution_error_state"`
	LastStateChange     time.Time            `json:"last_state_change"`
	StateChanges        int                  `json:"state_changes"`
	CustomizeConfig     jsonutils.JSONObject `json:"customize_config"`
	ResType             string               `json:"res_type"`
}

SAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SAlert.

type SAlertDashBoard

type SAlertDashBoard struct {
	// db.SVirtualResourceBase
	apis.SEnabledResourceBase
	apis.SStatusStandaloneResourceBase
	apis.SScopedResourceBase
	Refresh string `json:"refresh"`
}

SAlertDashBoard is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SAlertDashBoard.

type SAlertDashboardPanel

type SAlertDashboardPanel struct {
	apis.SVirtualJointResourceBase
	DashboardId string `json:"dashboard_id"`
	PanelId     string `json:"panel_id"`
}

SAlertDashboardPanel is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SAlertDashboardPanel.

type SAlertPanel

type SAlertPanel struct {
	apis.SStatusStandaloneResourceBase
	apis.SScopedResourceBase
	Settings jsonutils.JSONObject `json:"settings"`
	Message  string               `json:"message"`
}

SAlertPanel is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SAlertPanel.

type SAlertRecord

type SAlertRecord struct {
	// db.SVirtualResourceBase
	apis.SEnabledResourceBase
	apis.SStatusStandaloneResourceBase
	SMonitorScopedResource
	AlertId   string               `json:"alert_id"`
	Level     string               `json:"level"`
	State     string               `json:"state"`
	SendState string               `json:"send_state"`
	EvalData  jsonutils.JSONObject `json:"eval_data"`
	AlertRule jsonutils.JSONObject `json:"alert_rule"`
	ResType   string               `json:"res_type"`
}

SAlertRecord is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SAlertRecord.

type SAlertRecordShield

type SAlertRecordShield struct {
	// db.SVirtualResourceBase
	apis.SEnabledResourceBase
	apis.SStatusStandaloneResourceBase
	SMonitorScopedResource
	AlertId   string    `json:"alert_id"`
	ResId     string    `json:"res_id"`
	ResType   string    `json:"res_type"`
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
}

SAlertRecordShield is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SAlertRecordShield.

type SAlertResource

type SAlertResource struct {
	apis.SStandaloneResourceBase
	Type string `json:"type"`
}

SAlertResource is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SAlertResource.

type SCommonAlert

type SCommonAlert struct {
	SAlert
}

SCommonAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SCommonAlert.

type SDataSource

type SDataSource struct {
	apis.SStandaloneResourceBase
	Type      string `json:"type"`
	Url       string `json:"url"`
	User      string `json:"user"`
	Password  string `json:"password"`
	Database  string `json:"database"`
	IsDefault *bool  `json:"is_default,omitempty"`
}

SDataSource is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SDataSource.

type SMeterAlert

type SMeterAlert struct {
	SV1Alert
}

SMeterAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMeterAlert.

type SMetric

type SMetric struct {
	apis.SVirtualJointResourceBase
	MeasurementId string `json:"measurement_id"`
	FieldId       string `json:"field_id"`
}

SMetric is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMetric.

type SMetricField

type SMetricField struct {
	// db.SVirtualResourceBase
	apis.SEnabledResourceBase
	apis.SStatusStandaloneResourceBase
	apis.SScopedResourceBase
	DisplayName string `json:"display_name"`
	Unit        string `json:"unit"`
	ValueType   string `json:"value_type"`
	Score       int    `json:"score"`
}

SMetricField is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMetricField.

type SMetricMeasurement

type SMetricMeasurement struct {
	// db.SVirtualResourceBase
	apis.SEnabledResourceBase
	apis.SStatusStandaloneResourceBase
	apis.SScopedResourceBase
	ResType     string `json:"res_type"`
	Database    string `json:"database"`
	DisplayName string `json:"display_name"`
	Score       int    `json:"score"`
}

SMetricMeasurement is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMetricMeasurement.

type SMigrationAlert

type SMigrationAlert struct {
	SAlert
	MetricType   string               `json:"metric_type"`
	MigrateNotes jsonutils.JSONObject `json:"migrate_notes"`
}

SMigrationAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMigrationAlert.

type SMonitorResource

type SMonitorResource struct {
	apis.SVirtualResourceBase
	apis.SEnabledResourceBase
	AlertState string `json:"alert_state"`
	ResId      string `json:"res_id"`
	ResType    string `json:"res_type"`
}

SMonitorResource is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMonitorResource.

type SMonitorResourceAlert

type SMonitorResourceAlert struct {
	apis.SJointResourceBase
	MonitorResourceId string               `json:"monitor_resource_id"`
	AlertId           string               `json:"alert_id"`
	AlertRecordId     string               `json:"alert_record_id"`
	ResType           string               `json:"res_type"`
	AlertState        string               `json:"alert_state"`
	SendState         string               `json:"send_state"`
	TriggerTime       time.Time            `json:"trigger_time"`
	Data              jsonutils.JSONObject `json:"data"`
}

SMonitorResourceAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMonitorResourceAlert.

type SMonitorScopedResource

type SMonitorScopedResource struct {
	apis.SScopedResourceBase
}

SMonitorScopedResource is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMonitorScopedResource.

type SNodeAlert

type SNodeAlert struct {
	SCommonAlert
}

SNodeAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SNodeAlert.

type SNotification

type SNotification struct {
	apis.SVirtualResourceBase
	Type                  string `json:"type"`
	IsDefault             bool   `json:"is_default"`
	SendReminder          bool   `json:"send_reminder"`
	DisableResolveMessage bool   `json:"disable_resolve_message"`
	// unit is second
	Frequency            int64                `json:"frequency"`
	Settings             jsonutils.JSONObject `json:"settings"`
	LastSendNotification time.Time            `json:"last_send_notification"`
}

SNotification is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SNotification.

type SV1Alert

type SV1Alert struct {
	SAlert
}

SV1Alert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SV1Alert.

type SendWebhookSync

type SendWebhookSync struct {
	Url         string
	User        string
	Password    string
	Body        string
	HttpMethod  string
	HttpHeader  map[string]string
	ContentType string
}

type SimpleQueryInput

type SimpleQueryInput struct {
	// 资源Id, 可以不填, 代表查询指定监控的所有监控数据
	Id string `json:"id"`
	// 查询指定数据库
	// default: telegraf
	Database string `json:"database"`
	// 监控指标: https://github.com/codelinz/cloudpods/blob/monitor/pkg/cloudprovider/metrics.go
	MetricName string `json:"metric_name"`
	// 开始时间
	StartTime time.Time `json:"start_time"`
	// 结束时间
	EndTime time.Time `json:"end_time"`
	// 指定标签
	Tags map[string]string `json:"tag_pairs"`
}

type SimpleQueryOutput

type SimpleQueryOutput struct {
	Id    string    `json:"id"`
	Time  time.Time `json:"time"`
	Value float64   `json:"value"`
}

type TimePoint

type TimePoint []interface{}

func NewTimePoint

func NewTimePoint(value *float64, timestamp float64) TimePoint

func NewTimePointByVal

func NewTimePointByVal(value float64, timestamp float64) TimePoint

func (TimePoint) IsValid

func (p TimePoint) IsValid() bool

func (TimePoint) IsValids

func (p TimePoint) IsValids() bool

func (TimePoint) PointValueStr

func (p TimePoint) PointValueStr() []string

func (TimePoint) Timestamp

func (p TimePoint) Timestamp() float64

func (TimePoint) Value

func (p TimePoint) Value() float64

func (TimePoint) Values

func (p TimePoint) Values() []float64

type TimeSeries

type TimeSeries struct {
	// RawName is used to frontend displaying the curve name
	RawName string            `json:"raw_name"`
	Columns []string          `json:"columns"`
	Name    string            `json:"name"`
	Points  TimeSeriesPoints  `json:"points"`
	Tags    map[string]string `json:"tags,omitempty"`
}

type TimeSeriesPoints

type TimeSeriesPoints []TimePoint

func NewTimeSeriesPointsFromArgs

func NewTimeSeriesPointsFromArgs(values ...float64) TimeSeriesPoints

type TimeSeriesSlice

type TimeSeriesSlice []*TimeSeries

type V1AlertListInput

type V1AlertListInput struct {
	AlertListInput
}

type V1AlertUpdateInput

type V1AlertUpdateInput struct {
	AlertUpdateInput
}

Jump to

Keyboard shortcuts

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