From 9bf831aeb25ebdc6cc1ea77d010d0682a9b7cbef Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Thu, 28 Aug 2014 22:50:46 +0000 Subject: [PATCH] Set 'time' column in InfluxDB driver to preserve precision of stats even while batching writes to the DB. --- storage/influxdb/influxdb.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/influxdb/influxdb.go b/storage/influxdb/influxdb.go index a1e9fe3f..25f46188 100644 --- a/storage/influxdb/influxdb.go +++ b/storage/influxdb/influxdb.go @@ -38,7 +38,7 @@ type influxdbStorage struct { } const ( - colTimestamp string = "timestamp" + colTimestamp string = "time" colMachineName string = "machine" colContainerName string = "container_name" colCpuCumulativeUsage string = "cpu_cumulative_usage" @@ -67,7 +67,7 @@ func (self *influxdbStorage) containerStatsToValues( // Timestamp columns = append(columns, colTimestamp) - values = append(values, stats.Timestamp.Format(time.RFC3339Nano)) + values = append(values, stats.Timestamp.Unix()) // Machine name columns = append(columns, colMachineName) @@ -274,7 +274,7 @@ func (self *influxdbStorage) AddStats(ref info.ContainerReference, stats *info.C } }() if len(seriesToFlush) > 0 { - err := self.client.WriteSeries(seriesToFlush) + err := self.client.WriteSeriesWithTimePrecision(seriesToFlush, influxdb.Second) if err != nil { return fmt.Errorf("failed to write stats to influxDb - %s", err) }