mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Merge pull request #1778 from mattbostock/fix_annotations
promql: Fix annotations conflated with labels
This commit is contained in:
commit
4d1985e405
|
@ -15,8 +15,43 @@ package promql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/prometheus/common/model"
|
||||||
|
"github.com/prometheus/prometheus/storage/metric"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestStatementString(t *testing.T) {
|
||||||
|
in := &AlertStmt{
|
||||||
|
Name: "FooAlert",
|
||||||
|
Expr: &BinaryExpr{
|
||||||
|
Op: itemGTR,
|
||||||
|
LHS: &VectorSelector{
|
||||||
|
Name: "foo",
|
||||||
|
LabelMatchers: metric.LabelMatchers{
|
||||||
|
{Type: metric.Equal, Name: model.MetricNameLabel, Value: "bar"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RHS: &NumberLiteral{10},
|
||||||
|
},
|
||||||
|
Duration: 5 * time.Minute,
|
||||||
|
Labels: model.LabelSet{"foo": "bar"},
|
||||||
|
Annotations: model.LabelSet{
|
||||||
|
"notify": "team-a",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := `ALERT FooAlert
|
||||||
|
IF foo > 10
|
||||||
|
FOR 5m
|
||||||
|
LABELS {foo="bar"}
|
||||||
|
ANNOTATIONS {notify="team-a"}`
|
||||||
|
|
||||||
|
if in.String() != expected {
|
||||||
|
t.Fatalf("expected:\n%s\ngot:\n%s\n", expected, in.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestExprString(t *testing.T) {
|
func TestExprString(t *testing.T) {
|
||||||
// A list of valid expressions that are expected to be
|
// A list of valid expressions that are expected to be
|
||||||
// returned as out when calling String(). If out is empty the output
|
// returned as out when calling String(). If out is empty the output
|
||||||
|
|
Loading…
Reference in a new issue