Telegraf metrics timestamp source


Is there a way to configure telegraf + influxdb so the metric timestamp

  • will be taken from influxdb host
  • telegraf would take metric time from a ntp server - not from host itself.

On the first glance that would looks strange :slight_smile: but:
I need to monitor a software test cluster which run test cases with intentional host time skew:
as an instance a test can shift host time back and forth in months or years.

Best regards,

Interesting use case. I can’t think of a way to do this out of the box, Telegraf always writes the timestamp and due to batching your timestamps would be off up to flush_interval. You could probably make a custom build that doesn’t write the timestamps quite easily though, I could show you what to change. I also found a program called faketime, perhaps it would be useful?

Hi Daniel,
Thanks for your feedback.

I would appreciate if you point to the code to change to make telegraf to not write timestamp. Or you can provide a patch(diff) if that would be more convenient to describe the change.

Unfortunately the faketime program is not appropriate for our use case:

  • a test is shifting time at the time the tested software is running
  • our software is cross platform and also running on windows os family but faketime does not support windows
diff --git a/plugins/serializers/influx/influx.go b/plugins/serializers/influx/influx.go
index a675add4b..b4f0eccf3 100644
--- a/plugins/serializers/influx/influx.go
+++ b/plugins/serializers/influx/influx.go
@@ -172,8 +172,6 @@ func (s *Serializer) buildHeader(m telegraf.Metric) error {
 func (s *Serializer) buildFooter(m telegraf.Metric) {
        s.footer = s.footer[:0]
-       s.footer = append(s.footer, ' ')
-       s.footer = strconv.AppendInt(s.footer, m.Time().UnixNano(), 10)
        s.footer = append(s.footer, '\n')