Fixed alert's unknown metrics handler

This commit is contained in:
KRAIEM Taha Yassine 2021-05-27 13:38:07 +02:00
parent ff1cd1e01f
commit 37fdc04693
2 changed files with 12 additions and 4 deletions

View file

@ -157,7 +157,11 @@ func (a *Alert) CanCheck() bool {
}
func (a *Alert) Build() (sq.SelectBuilder, error) {
colDef := LeftToDb[a.Query.Left]
colDef, ok := LeftToDb[a.Query.Left]
if !ok {
return sq.Select(), errors.New(fmt.Sprintf("!! unsupported metric '%s' from alert: %d:%s\n", a.Query.Left, a.AlertID, a.Name))
}
subQ := sq.
Select(colDef.formula + " AS value").
From(colDef.table).
@ -221,4 +225,4 @@ func (a *Alert) Build() (sq.SelectBuilder, error) {
return q, errors.New("unsupported detection method")
}
return q, nil
}
}

View file

@ -157,7 +157,11 @@ func (a *Alert) CanCheck() bool {
}
func (a *Alert) Build() (sq.SelectBuilder, error) {
colDef := LeftToDb[a.Query.Left]
colDef, ok := LeftToDb[a.Query.Left]
if !ok {
return sq.Select(), errors.New(fmt.Sprintf("!! unsupported metric '%s' from alert: %d:%s\n", a.Query.Left, a.AlertID, a.Name))
}
subQ := sq.
Select(colDef.formula + " AS value").
From(colDef.table).
@ -221,4 +225,4 @@ func (a *Alert) Build() (sq.SelectBuilder, error) {
return q, errors.New("unsupported detection method")
}
return q, nil
}
}