Skip to content

Commit 3c0b5fe

Browse files
committed
tech(alerting): add graphite dateformat replacer
1 parent 8cd1d17 commit 3c0b5fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/tsdb/graphite/graphite.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"net/http"
77
"net/url"
8+
"strings"
89
"time"
910

1011
"github.com/grafana/grafana/pkg/log"
@@ -30,7 +31,7 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
3031
result := &tsdb.BatchResult{}
3132

3233
params := url.Values{
33-
"from": []string{context.TimeRange.From},
34+
"from": []string{formatTimeRange(context.TimeRange.From)},
3435
"until": []string{context.TimeRange.To},
3536
"format": []string{"json"},
3637
"maxDataPoints": []string{"500"},
@@ -76,3 +77,7 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
7677
result.QueryResults["A"] = queryRes
7778
return result
7879
}
80+
81+
func formatTimeRange(input string) string {
82+
return strings.Replace(strings.Replace(input, "m", "min", -1), "M", "mon", -1)
83+
}

0 commit comments

Comments
 (0)