|
|
@ -257,16 +257,10 @@ func (p *parser) alertStmt() *AlertStmt {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
p.expect(itemSummary, ctx)
|
|
|
|
p.expect(itemSummary, ctx)
|
|
|
|
sum, err := strconv.Unquote(p.expect(itemString, ctx).val)
|
|
|
|
sum := trimOne(p.expect(itemString, ctx).val)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
p.error(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p.expect(itemDescription, ctx)
|
|
|
|
p.expect(itemDescription, ctx)
|
|
|
|
desc, err := strconv.Unquote(p.expect(itemString, ctx).val)
|
|
|
|
desc := trimOne(p.expect(itemString, ctx).val)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
p.error(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return &AlertStmt{
|
|
|
|
return &AlertStmt{
|
|
|
|
Name: name.val,
|
|
|
|
Name: name.val,
|
|
|
@ -663,10 +657,7 @@ func (p *parser) labelMatchers(operators ...itemType) metric.LabelMatchers {
|
|
|
|
p.errorf("operator must be one of %q, is %q", operators, op)
|
|
|
|
p.errorf("operator must be one of %q, is %q", operators, op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val, err := strconv.Unquote(p.expect(itemString, ctx).val)
|
|
|
|
val := trimOne(p.expect(itemString, ctx).val)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
p.error(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Map the item to the respective match type.
|
|
|
|
// Map the item to the respective match type.
|
|
|
|
var matchType metric.MatchType
|
|
|
|
var matchType metric.MatchType
|
|
|
@ -887,3 +878,14 @@ func parseDuration(ds string) (time.Duration, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dur, nil
|
|
|
|
return dur, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// trimOne removes the first and last character from a string.
|
|
|
|
|
|
|
|
func trimOne(s string) string {
|
|
|
|
|
|
|
|
if len(s) > 0 {
|
|
|
|
|
|
|
|
s = s[1:]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(s) > 0 {
|
|
|
|
|
|
|
|
s = s[:len(s)-1]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
}
|
|
|
|