fix(monitor): add target for suggestRuleListInput (#19554)

Co-authored-by: 马鸿飞 <mahongfei@yunion.cn>
This commit is contained in:
gouqi11
2024-02-26 20:18:50 +08:00
committed by GitHub
co-authored by 马鸿飞
parent 629c9982ab
commit 52b08e6e3e
3 changed files with 1 additions and 129 deletions
-72
View File
@@ -13,75 +13,3 @@
// limitations under the License.
package monitor
import (
"time"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/apis/compute"
)
type SuggestSysAlertListInput struct {
apis.VirtualResourceListInput
apis.EnabledResourceBaseListInput
compute.ManagedResourceListInput
//监控规则type:Rule Type
Type string `json:"type"`
ResId string `json:"res_id"`
}
type SuggestSysAlertCreateInput struct {
apis.VirtualResourceCreateInput
Enabled *bool `json:"enabled"`
MonitorConfig *SSuggestSysAlertSetting `json:"monitor_config"`
//转换成ResId
ResID string `json:"res_id"`
Type string `json:"type"`
//Problem jsonutils.JSONObject `json:"problem"`
Suggest string `json:"suggest"`
Action string `json:"action"`
RuleAt time.Time `json:"rule_at"`
}
type SuggestSysAlertDetails struct {
apis.VirtualResourceDetails
compute.CloudregionResourceInfo
RuleName string `json:"rule_name"`
ShowName string `json:"show_name"`
ResType string `json:"res_type"`
Suggest string `json:"suggest"`
Brand string `json:"brand"`
Account string `json:"account"`
ResName string `json:"res_name"`
CommonAlertMetricDetails []*CommonAlertMetricDetails `json:"common_alert_metric_details"`
}
type SuggestSysAlertUpdateInput struct {
apis.VirtualResourceBaseUpdateInput
Enabled *bool `json:"enabled"`
MonitorConfig *SSuggestSysAlertSetting `json:"monitor_config"`
//转换成ResId
ResID string `json:"res_id"`
Type string `json:"type"`
//Problem jsonutils.JSONObject `json:"problem"`
Suggest string `json:"suggest"`
Action string `json:"action"`
RuleAt time.Time `json:"rule_at"`
}
type SuggestAlertIngoreInput struct {
apis.ScopedResourceCreateInput
BatchIgnore bool `json:"batch_ignore"`
}
type SuggestAlertProblem struct {
Type string `json:"type"`
Description string `json:"description"`
}
-56
View File
@@ -15,8 +15,6 @@
package monitor
import (
"time"
"yunion.io/x/onecloud/pkg/apis"
)
@@ -32,13 +30,6 @@ const (
var PROPERTY_TYPE = []string{"databases", "measurements", "metric-measurement"}
var FilterSuggestRuleMeasureMentMap = map[SuggestDriverType]string{
SCALE_DOWN: "vm",
REDIS_UNREASONABLE: "dcs",
RDS_UNREASONABLE: "rds",
OSS_UNREASONABLE: "oss",
}
var METRIC_ATTRI = []string{METRIC_TAG, METRIC_FIELD}
type InfluxMeasurement struct {
@@ -55,53 +46,6 @@ type InfluxMeasurement struct {
Unit []string
}
type SuggestSysRuleListInput struct {
apis.StandaloneResourceListInput
apis.EnabledResourceBaseListInput
}
type SuggestSysRuleCreateInput struct {
apis.StandaloneResourceCreateInput
// 查询指标周期
Period string `json:"period"`
TimeFrom string `json:"time_from"`
Type string `json:"type"`
Enabled *bool `json:"enabled"`
Setting *SSuggestSysAlertSetting `json:"setting"`
IgnoreTimeFrom *bool `json:"ignore_time_from"`
}
type SuggestSysRuleUpdateInput struct {
apis.Meta
// 查询指标周期
Period string `json:"period"`
Name string `json:"name"`
Type string `json:"type"`
Setting *SSuggestSysAlertSetting `json:"setting"`
Enabled *bool `json:"enabled"`
ExecTime time.Time `json:"exec_time"`
IgnorePeriod *bool `json:"ignore_period"`
}
type SuggestSysRuleDetails struct {
apis.StandaloneResourceDetails
CommonAlertMetricDetails []*CommonAlertMetricDetails `json:"common_alert_metric_details"`
ID string `json:"id"`
Name string `json:"name"`
Setting *SSuggestSysAlertSetting `json:"setting"`
Enabled bool `json:"enabled"`
}
type SSuggestSysAlertSetting struct {
EIPUnused *EIPUnused `json:"eip_unused"`
DiskUnused *DiskUnused `json:"disk_unused"`
LBUnused *LBUnused `json:"lb_unused"`
ScaleRule *ScaleRule `json:"scale_rule"`
}
type EIPUnused struct {
}
+1 -1
View File
@@ -210,7 +210,7 @@ func (man *SMonitorResourceManager) OrderByExtraFields(
ctx context.Context,
q *sqlchemy.SQuery,
userCred mcclient.TokenCredential,
input monitor.SuggestSysAlertListInput,
input monitor.MonitorResourceListInput,
) (*sqlchemy.SQuery, error) {
var err error
q, err = man.SVirtualResourceBaseManager.OrderByExtraFields(ctx, q, userCred, input.VirtualResourceListInput)