Skip to content

Commit

Permalink
feat: csv parsers can handle unix timestamp
Browse files Browse the repository at this point in the history
If we try to use unix timestamp in the csv file, we will get an error.
This commit fixes that.
So you can have timestamp like : 1405544146 now.
  • Loading branch information
tkanos committed Nov 27, 2018
1 parent a22e6a8 commit c4f68c6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/parsers/csv/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,12 @@ outer:
var err error
metricTime, err = time.Parse(p.TimestampFormat, tStr)
if err != nil {
return nil, err
if t, errT := strconv.ParseInt(tStr, 10, 64); errT == nil {
// Try Unix format
metricTime = time.Unix(t, 0)
} else {
return nil, err
}
}
}

Expand Down

0 comments on commit c4f68c6

Please sign in to comment.