From 0a39c07af9acc9c4d6dfd7bdad5cd1eb7db66ce9 Mon Sep 17 00:00:00 2001 From: Alexander Saltykov Date: Mon, 20 May 2019 16:17:46 +0300 Subject: [PATCH 1/2] web/api/v1: alert value as string in alert/rules endpoints Signed-off-by: Alexander Saltykov --- web/api/v1/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/api/v1/api.go b/web/api/v1/api.go index bfb4aec9fd1..465594f549d 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -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), } } From 503620517932eeca766f483a9960e23c604a0ef3 Mon Sep 17 00:00:00 2001 From: Alexander Saltykov Date: Tue, 21 May 2019 12:06:14 +0300 Subject: [PATCH 2/2] update api docs for alert rules Signed-off-by: Alexander Saltykov --- docs/querying/api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/querying/api.md b/docs/querying/api.md index fba7e9ff0b3..d01f15ab14c 100644 --- a/docs/querying/api.md +++ b/docs/querying/api.md @@ -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" } ] },