mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
5cf5a0e8c4
This was preventing from reading data via /api/v1/prometheus/import . Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/750
22 lines
501 B
Go
22 lines
501 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
// GetTimestamp extracts unix timestamp in milliseconds from `timestamp` query arg.
|
|
//
|
|
// It returns 0 if there is no `timestamp` query arg.
|
|
func GetTimestamp(req *http.Request) (int64, error) {
|
|
ts := req.URL.Query().Get("timestamp")
|
|
if len(ts) == 0 {
|
|
return 0, nil
|
|
}
|
|
timestamp, err := strconv.ParseInt(ts, 10, 64)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("cannot parse `timestamp=%s` query arg: %w", ts, err)
|
|
}
|
|
return timestamp, nil
|
|
}
|