VictoriaMetrics/VictoriaMetrics · error
cannot parse timestamp milliseconds from %q: %w
Error message
cannot parse timestamp milliseconds from %q: %w
What it means
Raised in parseUnixTimestampMilliseconds (csvimport time format unix_ms) when fastfloat.ParseInt64 cannot parse the cell as an integer millisecond timestamp. The wrapped error explains the parse failure for the given cell value %q.
Source
Thrown at lib/protoparser/csvimport/column_descriptor.go:156
return nil, fmt.Errorf("unknown format for time parsing: %q; supported formats: unix_s, unix_ms, unix_ns, rfc3339", format)
}
}
func parseUnixTimestampSeconds(s string) (int64, error) {
n, err := fastfloat.ParseInt64(s)
if err != nil {
return 0, fmt.Errorf("cannot parse timestamp seconds from %q: %w", s, err)
}
if n > int64(1<<63-1)/1e3 {
return 0, fmt.Errorf("too big unix timestamp in seconds: %d; must be smaller than %d", n, int64(1<<63-1)/1e3)
}
return n * 1e3, nil
}
func parseUnixTimestampMilliseconds(s string) (int64, error) {
n, err := fastfloat.ParseInt64(s)
if err != nil {
return 0, fmt.Errorf("cannot parse timestamp milliseconds from %q: %w", s, err)
}
return n, nil
}
func parseUnixTimestampNanoseconds(s string) (int64, error) {
n, err := fastfloat.ParseInt64(s)
if err != nil {
return 0, fmt.Errorf("cannot parse timestamp nanoseconds from %q: %w", s, err)
}
return n / 1e6, nil
}
func parseRFC3339(s string) (int64, error) {
t, err := time.Parse(time.RFC3339, s)
if err != nil {
return 0, fmt.Errorf("cannot parse time in RFC3339 from %q: %w", s, err)
}
return t.UnixNano() / 1e6, nilView on GitHub (pinned to 5079fb58f1)
Solutions
- Fix the offending cell to a plain integer of milliseconds
- Replace sentinel values like 'N/A', 'null', or empty cells with real timestamps or drop those rows
- If data is a formatted date, switch the spec to time:rfc3339 or a custom format
- Trim whitespace, quotes, and BOM from cells before import
Example fix
// before (CSV cell)
N/A
cds, _ := csvimport.ParseColumnDescriptors("time:unix_ms,metric")
// after
1700000000000 Defensive patterns
Strategy: try-catch
Validate before calling
func isUnixMillis(v string) bool {
n, err := strconv.ParseInt(strings.TrimSpace(v), 10, 64)
return err == nil && n >= 0
} Try / catch
if err != nil && strings.Contains(err.Error(), "cannot parse timestamp milliseconds") {
// log the offending cell from the quoted %q and skip/repair that row
} Prevention
- Trim and normalize cells before Unmarshal
- Scan the time column once with strconv.ParseInt to find all bad rows up front
- Keep timestamp columns free of locale formatting in the upstream exporter
When it happens
Trigger: A row's time column with spec time:unix_ms contains non-numeric text, an empty string, a float with a fractional part that fails strict int parsing, a formatted date, or a number with thousands separators.
Common situations: CSV cells from spreadsheet exports with date formatting; whitespace/BOM; data actually in seconds (which would parse but yield wrong times — this error instead indicates true non-numeric junk like 'N/A' or 'null').
Related errors
- cannot parse timestamp seconds from %q: %w
- cannot parse timestamp nanoseconds from %q: %w
- cannot parse time in RFC3339 from %q: %w
- cannot parse time in custom format %q from %q: %w
- cannot parse timestamp from %q: %w
AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/39aed79f67be65b1.
Report an issue: GitHub.