@@ -594,8 +594,8 @@ func (h *httpAPI) DeleteSeries(ctx context.Context, matches []string, startTime
594594q .Add ("match[]" , m )
595595}
596596
597- q .Set ("start" , startTime . Format ( time . RFC3339Nano ))
598- q .Set ("end" , endTime . Format ( time . RFC3339Nano ))
597+ q .Set ("start" , formatTime ( startTime ))
598+ q .Set ("end" , formatTime ( endTime ))
599599
600600u .RawQuery = q .Encode ()
601601
@@ -659,7 +659,7 @@ func (h *httpAPI) Query(ctx context.Context, query string, ts time.Time) (model.
659659
660660q .Set ("query" , query )
661661if ! ts .IsZero () {
662- q .Set ("time" , ts . Format ( time . RFC3339Nano ))
662+ q .Set ("time" , formatTime ( ts ))
663663}
664664
665665_ , body , warnings , err := api .DoGetFallback (h .client , ctx , u , q )
@@ -675,16 +675,10 @@ func (h *httpAPI) QueryRange(ctx context.Context, query string, r Range) (model.
675675u := h .client .URL (epQueryRange , nil )
676676q := u .Query ()
677677
678- var (
679- start = r .Start .Format (time .RFC3339Nano )
680- end = r .End .Format (time .RFC3339Nano )
681- step = strconv .FormatFloat (r .Step .Seconds (), 'f' , 3 , 64 )
682- )
683-
684678q .Set ("query" , query )
685- q .Set ("start" , start )
686- q .Set ("end" , end )
687- q .Set ("step" , step )
679+ q .Set ("start" , formatTime ( r . Start ) )
680+ q .Set ("end" , formatTime ( r . End ) )
681+ q .Set ("step" , strconv . FormatFloat ( r . Step . Seconds (), 'f' , - 1 , 64 ) )
688682
689683_ , body , warnings , err := api .DoGetFallback (h .client , ctx , u , q )
690684if err != nil {
@@ -704,8 +698,8 @@ func (h *httpAPI) Series(ctx context.Context, matches []string, startTime time.T
704698q .Add ("match[]" , m )
705699}
706700
707- q .Set ("start" , startTime . Format ( time . RFC3339Nano ))
708- q .Set ("end" , endTime . Format ( time . RFC3339Nano ))
701+ q .Set ("start" , formatTime ( startTime ))
702+ q .Set ("end" , formatTime ( endTime ))
709703
710704u .RawQuery = q .Encode ()
711705
@@ -877,3 +871,7 @@ func (c apiClient) Do(ctx context.Context, req *http.Request) (*http.Response, [
877871return resp , []byte (result .Data ), warnings , err
878872
879873}
874+
875+ func formatTime (t time.Time ) string {
876+ return strconv .FormatFloat (float64 (t .UnixNano ())/ 1e9 , 'f' , - 1 , 64 )
877+ }
0 commit comments