1.0RC1 Precision not being set
Bug report
Relevant telegraf.conf:
As a note, I have precision = "s" in the [[outputs.influxdb]] section below however I also tried it in the [agent] section as well as the new sample-config seems to place it there.
# cat /etc/telegraf/telegraf.conf | egrep -v '^#|^[ ]+#|^$|^[ ]+$'
[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"
debug = false
quiet = false
hostname = ""
omit_hostname = false
[[outputs.influxdb]]
urls = ["http://remote-host:8086"] # required
database = "telegraf" # required
precision = "s"
retention_policy = ""
write_consistency = "any"
timeout = "5s"
username = "root"
password = "password"
[[inputs.cpu]]
percpu = true
totalcpu = true
fielddrop = ["time_*"]
System info:
Telegraf v1.0.0-RC1 InfluxDB v1.0.0-RC1
Steps to reproduce:
- Start the service with config above
- Connect to remote server and execute
tail /var/log/influxdb/influxd.log | grep 'telegraf' | grep 'precision' - POST write line protocol appears as ns precision instead of s
[httpd] 10.53.24.1 - root [31/Aug/2016:09:22:50 -0500] "POST /write?consistency=any&db=telegraf&precision=ns&rp= HTTP/1.1" 204 0 "-" "InfluxDBClient" 65963131-6f86-11e6-800c-000000000000 53780
Expected behavior:
POST communicates as precision=s
Actual behavior:
POST line shows that the data is being sent as ns precision
the influxdb output is now always sending metrics at ns precision. Timestamps are still always truncated to the precision setting in the agent section. So even though the write is with precision=ns in influxdb, the ns timestamp will always have 9 trailing zeros.
The reason for this is to prevent the influxdb output from pushing duplicate points through the system when using service input plugins.
For example, if you had the udp_listener input plugin which received two points that look like this:
cpu usage=99 1472654491000000000
cpu usage=95 1472654491000000001
These would then get truncated to a single point by the influxdb output s precision, and thus one of them would get lost:
cpu usage=99 1472654491
cpu usage=95 1472654491
With 9 trailing 0s, you will still get the same storage compression advantage as if you were sending with precision=s
@sparrc
I think I understand. So the agent is collecting all of the metrics and providing them a timestamp in second precision but is still passing all of the trailing zeroes to the output plugin. This is why I'm seeing a POST in ns on both the client/server.
So the optimization here is on the influxDB side where all of these trailing zeroes are compressed/dropped.
The data in the database backs up that it is collecting in seconds format but it is good to hear that that is still occuring:
> select usage_user from cpu LIMIT 5
name: cpu
---------
time usage_user
1472652950000000000 0.05002292717440627
1472652950000000000 0.09990009989991609
1472652950000000000 0.2002002002047568
1472652950000000000 0
1472652950000000000 0