web api: handle alert with Infinity/NaN values (#5582)

* web/api/v1: alert value as string in alert/rules endpoints

Signed-off-by: Alexander Saltykov <alexander-s@yandex-team.ru>
pull/5587/head
Alex Salt 6 years ago committed by Brian Brazil
parent 0652b518da
commit d6a4daa26a

@ -465,7 +465,7 @@ $ curl http://localhost:9090/api/v1/rules
"severity": "page"
},
"state": "firing",
"value": 1
"value": "1e+00"
}
],
"annotations": {
@ -522,7 +522,7 @@ $ curl http://localhost:9090/api/v1/alerts
"alertname": "my-alert"
},
"state": "firing",
"value": 1
"value": "1e+00"
}
]
},

@ -694,7 +694,7 @@ type Alert struct {
Annotations labels.Labels `json:"annotations"`
State string `json:"state"`
ActiveAt *time.Time `json:"activeAt,omitempty"`
Value float64 `json:"value"`
Value string `json:"value"`
}
func (api *API) alerts(r *http.Request) apiFuncResult {
@ -721,7 +721,7 @@ func rulesAlertsToAPIAlerts(rulesAlerts []*rules.Alert) []*Alert {
Annotations: ruleAlert.Annotations,
State: ruleAlert.State.String(),
ActiveAt: &ruleAlert.ActiveAt,
Value: ruleAlert.Value,
Value: strconv.FormatFloat(ruleAlert.Value, 'e', -1, 64),
}
}

Loading…
Cancel
Save