fix(monitor): skip disable account alert (#24979)

This commit is contained in:
屈轩
2026-06-05 16:14:25 +08:00
committed by GitHub
parent 354408b656
commit 3ac9178c61
4 changed files with 35 additions and 0 deletions
+5
View File
@@ -360,6 +360,10 @@ type CloudaccountDetail struct {
}
func (self CloudaccountDetail) GetMetricTags() map[string]string {
enabled := "true"
if self.Enabled != nil && !*self.Enabled {
enabled = "false"
}
ret := map[string]string{
"id": self.Id,
"cloudaccount_id": self.Id,
@@ -371,6 +375,7 @@ func (self CloudaccountDetail) GetMetricTags() map[string]string {
"tenant_id": self.ProjectId,
"tenant": self.Project,
"status": self.Status,
"enabled": enabled,
}
return AppendMetricTags(ret, self.MetadataResourceInfo, self.ProjectizedResourceInfo)
}
+1
View File
@@ -184,6 +184,7 @@ var (
"brand": "brand",
"domain_id": "domain_id",
"project_domain": "project_domain",
"enabled": "enabled",
}
TenantTags = map[string]string{
+6
View File
@@ -182,6 +182,11 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) (*alerting.Conditio
}
for _, series := range seriesList {
if c.ResType == monitor.METRIC_RES_TYPE_CLOUDACCOUNT {
if enabled, ok := series.Tags["enabled"]; ok && enabled == "false" {
continue
}
}
if c.IsCloudResource() {
isLatestOfSerie, resource := c.serieIsLatestResource(nil, series)
if !isLatestOfSerie {
@@ -557,6 +562,7 @@ func newQueryCondition(model *monitor.AlertCondition, index int) (*QueryConditio
cond.checkGroupByField()
cond.setResType()
models.AppendCloudAccountDefaultQueryTags(&cond.Query.Model, true)
return cond, nil
}
+23
View File
@@ -505,6 +505,29 @@ func setDefaultValue(
Condition: "and",
})
}
AppendCloudAccountDefaultQueryTags(&query.Model, isAlert)
}
// AppendCloudAccountDefaultQueryTags appends default tag filters for cloud account metrics.
func AppendCloudAccountDefaultQueryTags(model *monitor.MetricQuery, isAlert bool) {
if !isAlert || model == nil {
return
}
metricMeasurement, _ := MetricMeasurementManager.GetCache().Get(model.Measurement)
if metricMeasurement == nil || metricMeasurement.ResType != monitor.METRIC_RES_TYPE_CLOUDACCOUNT {
return
}
for _, tagFilter := range model.Tags {
if tagFilter.Key == "enabled" {
return
}
}
model.Tags = append(model.Tags, monitor.MetricQueryTag{
Key: "enabled",
Operator: "=",
Value: "true",
Condition: "and",
})
}
func checkQueryGroupBy(query *monitor.AlertQuery, inputQuery *monitor.MetricQueryInput, isAlert bool) {