@@ -594,8 +594,8 @@ func (h *httpAPI) DeleteSeries(ctx context.Context, matches []string, startTime
594
594
q .Add ("match[]" , m )
595
595
}
596
596
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 ))
599
599
600
600
u .RawQuery = q .Encode ()
601
601
@@ -659,7 +659,7 @@ func (h *httpAPI) Query(ctx context.Context, query string, ts time.Time) (model.
659
659
660
660
q .Set ("query" , query )
661
661
if ! ts .IsZero () {
662
- q .Set ("time" , ts . Format ( time . RFC3339Nano ))
662
+ q .Set ("time" , formatTime ( ts ))
663
663
}
664
664
665
665
_ , 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.
675
675
u := h .client .URL (epQueryRange , nil )
676
676
q := u .Query ()
677
677
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
-
684
678
q .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 ) )
688
682
689
683
_ , body , warnings , err := api .DoGetFallback (h .client , ctx , u , q )
690
684
if err != nil {
@@ -704,8 +698,8 @@ func (h *httpAPI) Series(ctx context.Context, matches []string, startTime time.T
704
698
q .Add ("match[]" , m )
705
699
}
706
700
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 ))
709
703
710
704
u .RawQuery = q .Encode ()
711
705
@@ -877,3 +871,7 @@ func (c apiClient) Do(ctx context.Context, req *http.Request) (*http.Response, [
877
871
return resp , []byte (result .Data ), warnings , err
878
872
879
873
}
874
+
875
+ func formatTime (t time.Time ) string {
876
+ return strconv .FormatFloat (float64 (t .UnixNano ())/ 1e9 , 'f' , - 1 , 64 )
877
+ }
0 commit comments