I happened to notice today that I have had a bug in my Telegraf agent
section configuration for a long time that I hadn’t noticed before, and Telegraf hasn’t complained about this bug either.
It is about the precision
parameter in the agent
section.
The documentation says:
Valid values are
ns
,us
(orµs
),ms
, ands
So I had the following configuration in my agent
section:
[agent]
interval = "1s"
precision = "ns"
The configuration works and there was no error message, but the precision
parameter is ignored in this case and replaced by the value in interval
. I noticed this behaviour, when I was working with higher resolution timestamps and wondered why all my timestamps were rounded to 1s
after the output from Telegraf.
The correct configuration should be:
[agent]
interval = "1s"
precision = "1ns"
In my opinion, the documentation here is misleading, and if Telegraf doesn’t complain, you may not notice this error unless you look very closely at your output timestamps.
Also, the behavior of the precision
parameter in an input plugin is different, there Telegraf complains.
This does not work:
[[inputs.file]]
precision = "ns"
[telegraf] Error running agent: Error loading config file xxx.conf: error parsing file, line 31:{363 455}: error parsing duration: time: invalid duration “ns”
This works and of course overrides the global precision
setting of the agent
section:
[[inputs.file]]
precision = "1ns"
@Anaisdg
IMHO this inconsistent behaviour of the precision
parameter should be fixed in the agent
section?