@@ -64,10 +64,29 @@ func getStartTime(params url.Values) (string, error) {
6464 }
6565 start = strconv .FormatInt (time .Now ().Unix ()- r , 10 )
6666 }
67+ } else {
68+ // Make sure it is a valid int
69+ _ , err := strconv .ParseInt (start , 10 , 64 )
70+ if err != nil {
71+ return "" , errors .New ("Could not parse start time: " + err .Error ())
72+ }
6773 }
6874 return start , nil
6975}
7076
77+ // getEndTime will parse end time and ceil it to the next second
78+ func getEndTime (params url.Values ) (string , error ) {
79+ end := params .Get (endTimeKey )
80+ if len (end ) > 0 {
81+ r , err := strconv .ParseInt (end , 10 , 64 )
82+ if err != nil {
83+ return "" , errors .New ("Could not parse end time: " + err .Error ())
84+ }
85+ end = strconv .Itoa (int (r ) + 1 )
86+ }
87+ return end , nil
88+ }
89+
7190// getLimit returns limit as string (used for logQL) and as int (used to check if reached)
7291func getLimit (params url.Values ) (string , int , error ) {
7392 limit := params .Get (limitKey )
@@ -111,7 +130,10 @@ func getFlows(cfg loki.Config, client httpclient.Caller, params url.Values) (*mo
111130 if err != nil {
112131 return nil , http .StatusBadRequest , err
113132 }
114- end := params .Get (endTimeKey )
133+ end , err := getEndTime (params )
134+ if err != nil {
135+ return nil , http .StatusBadRequest , err
136+ }
115137 limit , reqLimit , err := getLimit (params )
116138 if err != nil {
117139 return nil , http .StatusBadRequest , err
0 commit comments