From c4f68c6c13c230ecf863d87085aa285b468f71fa Mon Sep 17 00:00:00 2001 From: Felipe Dutra Tine e Silva Date: Tue, 27 Nov 2018 15:27:50 -0500 Subject: [PATCH] feat: csv parsers can handle unix timestamp 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. --- plugins/parsers/csv/parser.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/parsers/csv/parser.go b/plugins/parsers/csv/parser.go index f18068eb70075..b9e3fbc99b109 100644 --- a/plugins/parsers/csv/parser.go +++ b/plugins/parsers/csv/parser.go @@ -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 + } } }