tech(alerting): add graphite dateformat replacer

This commit is contained in:
bergquist 2016-06-10 13:26:19 +02:00
parent 8cd1d17916
commit 3c0b5fe78e

View File

@ -5,6 +5,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
"github.com/grafana/grafana/pkg/log"
@ -30,7 +31,7 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
result := &tsdb.BatchResult{}
params := url.Values{
"from": []string{context.TimeRange.From},
"from": []string{formatTimeRange(context.TimeRange.From)},
"until": []string{context.TimeRange.To},
"format": []string{"json"},
"maxDataPoints": []string{"500"},
@ -76,3 +77,7 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
result.QueryResults["A"] = queryRes
return result
}
func formatTimeRange(input string) string {
return strings.Replace(strings.Replace(input, "m", "min", -1), "M", "mon", -1)
}