mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-06 21:52:54 +08:00
fix(monitor): only query enabled host for alerting (#15297)
This commit is contained in:
@@ -22,5 +22,5 @@ import (
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(modules.MonitorResourceManager)
|
||||
cmd.Get("", new(options.MonitorResourceJointAlertOptions))
|
||||
cmd.GetProperty(new(options.MonitorResourceJointAlertOptions))
|
||||
}
|
||||
|
||||
@@ -188,13 +188,18 @@ type EvalMatch struct {
|
||||
type AlertTestRunOutput struct {
|
||||
apis.Meta
|
||||
|
||||
Firing bool `json:"firing"`
|
||||
EvalMatches []*EvalMatch `json:"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"`
|
||||
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 AlertPauseInput struct {
|
||||
|
||||
@@ -27,6 +27,6 @@ func (o *MonitorResourceJointAlertOptions) Params() (jsonutils.JSONObject, error
|
||||
return options.ListStructToParams(o)
|
||||
}
|
||||
|
||||
func (o *MonitorResourceJointAlertOptions) GetId() string {
|
||||
func (o *MonitorResourceJointAlertOptions) Property() string {
|
||||
return "alert"
|
||||
}
|
||||
|
||||
@@ -565,7 +565,8 @@ func (c *QueryCondition) getOnecloudResources() ([]jsonutils.JSONObject, error)
|
||||
switch c.ResType {
|
||||
case monitor.METRIC_RES_TYPE_HOST:
|
||||
query := jsonutils.NewDict()
|
||||
query.Set("host-type", jsonutils.NewString(hostconsts.TELEGRAF_TAG_KEY_HYPERVISOR))
|
||||
query.Set("host_type", jsonutils.NewString(hostconsts.TELEGRAF_TAG_KEY_HYPERVISOR))
|
||||
query.Set("enabled", jsonutils.NewInt(1))
|
||||
allResources, err = ListAllResources(&mc_mds.Hosts, query)
|
||||
case monitor.METRIC_RES_TYPE_GUEST:
|
||||
allResources, err = ListAllResources(&mc_mds.Servers, query)
|
||||
|
||||
@@ -254,13 +254,18 @@ func (_ AlertRuleTester) DoTest(ruleDef *models.SAlert, userCred mcclient.TokenC
|
||||
|
||||
func (ctx *EvalContext) ToTestRunResult() *monitor.AlertTestRunOutput {
|
||||
return &monitor.AlertTestRunOutput{
|
||||
Firing: ctx.Firing,
|
||||
EvalMatches: ctx.EvalMatches,
|
||||
Logs: ctx.Logs,
|
||||
Error: ctx.Error,
|
||||
ConditionEvals: ctx.ConditionEvals,
|
||||
StartTime: ctx.StartTime,
|
||||
EndTime: ctx.EndTime,
|
||||
Firing: ctx.Firing,
|
||||
IsTestRun: ctx.IsTestRun,
|
||||
IsDebug: ctx.IsDebug,
|
||||
EvalMatches: ctx.EvalMatches,
|
||||
AlertOKEvalMatches: ctx.AlertOkEvalMatches,
|
||||
Logs: ctx.Logs,
|
||||
Error: ctx.Error,
|
||||
ConditionEvals: ctx.ConditionEvals,
|
||||
StartTime: ctx.StartTime,
|
||||
EndTime: ctx.EndTime,
|
||||
NoDataFound: ctx.NoDataFound,
|
||||
PrevAlertState: string(ctx.PrevAlertState),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user