# Telegraf doesn't work with custom timestamp \[line protocol\]

**URL:** <https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200>\
**Category:** InfluxDB 2\
**Tags:** influxdb, telegraf\
**Created:** [December 5, 2019, 11:01am UTC](https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200 "2019-12-05T11:01:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hemant\_Shinde1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hemant_shinde1/32/4009_2.png) [@Hemant\_Shinde1](https://community.influxdata.com/u/Hemant_Shinde1)\
**Post date:** [December 5, 2019, 11:01am UTC](https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200/1 "2019-12-05T11:01:38Z")

</div>

Using InfluxDB Cloud.  
I have configured a telegraf agent to receive MQTT msgs and posting them to InfluxDB.  
It works well when I don’t provide timestamp in the messages.  
i.e. when messages are like below:

> power,botid=bot1 p=2,pf=2  
> power,botid=bot1 p=3,pf=3

I can see those messages in the Influx Dashboard.  
But when I try to use timestamp, I don’t see any errors from telegraf, however I don’t see the messages in the Influx DB graphs.  
For example.

> power,botid=bot1 p=2,pf=2 1575536708  
> power,botid=bot1 p=3,pf=3 1575536709

I tried the nanosecond version of timestamp, but it still didn’t work. What might be the issue?

Telegraf conf file for reference:

> [global\_tags]  
> [agent]  
> interval = “10s”  
> round\_interval = true  
> metric\_batch\_size = 1000  
> metric\_buffer\_limit = 10000  
> collection\_jitter = “0s”  
> flush\_interval = “10s”  
> flush\_jitter = “0s”  
> precision = “s”  
> debug = true  
> logfile = “/var/log/telegraf/abc”  
> [[outputs.influxdb\_v2]]  
> urls = [“”]  
> token = “”  
> organization = “”  
> bucket = “mybucket”  
> [[inputs.mqtt\_consumer]]  
> servers = [“tcp://127.0.0.1:1883”]  
> topics = [  
> “test”,  
> qos =2  
> username = “user”  
> password = “pass”  
> data\_format = “influx”

---

<div class="post-metadata">

**Author:** ![davidgs](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/davidgs/32/6936_2.png) [@davidgs](https://community.influxdata.com/u/davidgs)\
**Post date:** [December 5, 2019, 8:29pm UTC](https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200/2 "2019-12-05T20:29:16Z")

</div>

So that timestamp is in seconds (it appears). If you convert that to nanoseconds, but don’t add enough zeros, `157553670800000000` it turns into **GMT** : Sunday, December 29, 1974 12:54:30.800 PM so that would be why you don’t see it in the dashboard. The nanosecond timestamp format would be `1575536708000000000` or **GMT** : Thursday, December 5, 2019 9:05:08 AM

I think you have a timestamp conversion problem. I recognize this because I do it all the time and wonder where my data is, when really it’s either _way_ in the past, or in the future. 🙂

dg

---

<div class="post-metadata">

**Author:** ![Hemant\_Shinde1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hemant_shinde1/32/4009_2.png) [@Hemant\_Shinde1](https://community.influxdata.com/u/Hemant_Shinde1)\
**Post date:** [December 6, 2019, 4:13am UTC](https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200/3 "2019-12-06T04:13:02Z")

</div>

Thanks, so much for your answer. I realize my mistake.  
But I thought that specifying the agent interval to 10s would allow entries to be passed at the granularity of seconds. Isn’t that true? Is there any other option to send timestamp in seconds instead of nanoseconds?

---

<div class="post-metadata">

**Author:** ![davidgs](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/davidgs/32/6936_2.png) [@davidgs](https://community.influxdata.com/u/davidgs)\
**Post date:** [December 6, 2019, 1:38pm UTC](https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200/4 "2019-12-06T13:38:15Z")

</div>

Hi @Hemant_Shinde1,

The interval is the collection interval, what you’re after is the `precision`. Valid precisions are `ns` , `us` or `µs` , `ms` , and `s` . Set `precision = 's' ` and you should be all set.

dg

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [December 6, 2019, 6:50pm UTC](https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200/5 "2019-12-06T18:50:21Z")

</div>

The agent `precision` option sets timestamp rounding for polling plugins, but doesn’t affect `mqtt_consumer`. If you decide to set it then make sure to include a scalar value too (`precision="1s"`). Timestamp format/units is a property of the data format and with line protocol it always uses nanoseconds.

There is one edge case where it is allowed to use a different precision in the `influxdb_listener`, but I highly recommend to skip it and always use nanosecond precision when writing line protocol.

---

<div class="post-metadata">

**Author:** ![Hemant\_Shinde](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hemant_shinde/32/4008_2.png) [@Hemant\_Shinde](https://community.influxdata.com/u/Hemant_Shinde)\
**Post date:** [December 8, 2019, 1:13pm UTC](https://community.influxdata.com/t/telegraf-doesnt-work-with-custom-timestamp-line-protocol/12200/6 "2019-12-08T13:13:01Z")

</div>

Thanks for clarification and the recommendation. I will follow that.
