Skip to content

Commit

Permalink
pkg/rules/rulespb.AlertState: marshal JSON as lowercase
Browse files Browse the repository at this point in the history
Currently, alert state is rendered as upper case.
In Prometheus it is lower case.
This fixes it.

Signed-off-by: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>
  • Loading branch information
s-urbaniak committed Jul 2, 2020
1 parent 482d0f2 commit 4013d66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/rules/rulespb/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (x *AlertState) UnmarshalJSON(entry []byte) error {
}

func (x *AlertState) MarshalJSON() ([]byte, error) {
return []byte(strconv.Quote(x.String())), nil
return []byte(strconv.Quote(strings.ToLower(x.String()))), nil
}

// Compare compares alert state x and y and returns:
Expand Down
6 changes: 3 additions & 3 deletions pkg/rules/rulespb/custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,23 @@ func TestJSONUnmarshalMarshal(t *testing.T) {
Annotations: labels.Labels{
{Name: "annotation1", Value: "2"},
},
State: "INACTIVE",
State: "inactive",
ActiveAt: nil,
Value: "1",
PartialResponseStrategy: "WARN",
},
{
Labels: nil,
Annotations: nil,
State: "FIRING",
State: "firing",
ActiveAt: &twoHoursAgo,
Value: "2143",
PartialResponseStrategy: "ABORT",
},
},
LastError: "1",
Duration: 60,
State: "PENDING",
State: "pending",
LastEvaluation: now.Add(-1 * time.Minute),
EvaluationTime: 1.1,
},
Expand Down

0 comments on commit 4013d66

Please sign in to comment.