From 689230161cdc2a538f73aa8470f500f861945bbc Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Mon, 24 Feb 2025 10:27:33 +0100 Subject: [PATCH] Stay backward compatible --- pkg/services/ngalert/state/historian/loki_http.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/services/ngalert/state/historian/loki_http.go b/pkg/services/ngalert/state/historian/loki_http.go index 5d84998a84a..3720d7c7744 100644 --- a/pkg/services/ngalert/state/historian/loki_http.go +++ b/pkg/services/ngalert/state/historian/loki_http.go @@ -159,6 +159,12 @@ type Sample struct { } func (r *Sample) MarshalJSON() ([]byte, error) { + // For backward compatibility, if M is nil, we don't include it in the JSON. + if r.M == nil { + return json.Marshal([]any{ + fmt.Sprintf("%d", r.T.UnixNano()), r.V, + }) + } return json.Marshal([]any{ fmt.Sprintf("%d", r.T.UnixNano()), r.V, r.M, })