diff --git a/docs/Single-server-VictoriaMetrics.md b/docs/Single-server-VictoriaMetrics.md index 68bee367f..6f9421ca7 100644 --- a/docs/Single-server-VictoriaMetrics.md +++ b/docs/Single-server-VictoriaMetrics.md @@ -552,8 +552,7 @@ Extra labels may be added to all the imported metrics by passing `extra_label=na For example, `/api/v1/import/prometheus?extra_label=foo=bar` would add `{foo="bar"}` label to all the imported metrics. If timestamp is missing in ` ` Prometheus exposition format line, then the current timestamp is used during data ingestion. -It can be overriden by passing unix timestamp in seconds via `timestamp` query arg. The value may be fractional when millisecond precision is needed. -For example, `/api/v1/import/prometheus?timestamp=1594370496.905`. +It can be overriden by passing unix timestamp in *milliseconds* via `timestamp` query arg. For example, `/api/v1/import/prometheus?timestamp=1594370496905`. VictoriaMetrics accepts arbitrary number of lines in a single request to `/api/v1/import/prometheus`, i.e. it supports data streaming. diff --git a/lib/protoparser/common/timestamp.go b/lib/protoparser/common/timestamp.go index 7016b98ad..0433f6808 100644 --- a/lib/protoparser/common/timestamp.go +++ b/lib/protoparser/common/timestamp.go @@ -6,7 +6,7 @@ import ( "strconv" ) -// GetTimestamp extracts unix timestamp from `timestamp` query arg. +// 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) { @@ -14,10 +14,9 @@ func GetTimestamp(req *http.Request) (int64, error) { if len(ts) == 0 { return 0, nil } - timestamp, err := strconv.ParseFloat(ts, 64) + timestamp, err := strconv.ParseInt(ts, 10, 64) if err != nil { return 0, fmt.Errorf("cannot parse `timestamp=%s` query arg: %w", ts, err) } - // Convert seconds to milliseconds. - return int64(timestamp * 1e3), nil + return timestamp, nil }