Some Telegraf fields don't appear during test but arrive at InfluxDB anyway

I’d like a second opinion(s) on whether this behaviour is normal - and my understanding is wrong - or perhaps it’s a bug?

I’m using Telegraf v1.2.1 (git: release-1.2 3b6ffb344e5c03c1595d862282a6823ecb438cff) on a Raspberry Pi 3 (armhf architecture).

I’m using the following config for the CPU input plugin, because I’m not really interested in raw/jiffies values - only percentages:

[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false

When I run telegraf -test, I don’t see any output at all from the plugin:

...
* Plugin: inputs.cpu, Collection 1
* Plugin: inputs.disk, Collection 1
> disk,path=/,device=root,fstype=ext4,host=myhost inodes_free=423075i,inodes_used=52701i,total=7722041344i,free=4946735104i,used=2431152128i,used_percent=32.95187431783181,inodes_total=475776i 1490785312000000000
...

… yet there is definitely stuff going into my influxdb from the plugin when I run it properly with the exact same config:

> show field keys from cpu
name: cpu
fieldKey         fieldType
--------         ---------
usage_guest      float
usage_guest_nice float
usage_idle       float
usage_iowait     float
usage_irq        float
usage_nice       float
usage_softirq    float
usage_steal      float
usage_system     float
usage_user       float

> select usage_idle from cpu where host = 'myhost' order by time desc limit 10
name: cpu
time                usage_idle
----                ----------
1490786450000000000 99.89989989990681
1490786450000000000 98.97346019028585
1490786450000000000 99.70000000000255
1490786450000000000 98.70129870129765
1490786450000000000 97.58551307846399
1490786440000000000 97.59759759759973
1490786440000000000 99.49849548646664
1490786440000000000 99.89999999999782
1490786440000000000 98.89889889889315
1490786440000000000 98.97371714643343

I don’t understand why I don’t see anything during telegraf -test, if the plugin is seemingly reporting percentage usage data just fine.

FWIW, if I set collect_cpu_time = true, I do see output during telegraf -test - but it’s all the jiffy/times stuff that I’m not interested in. The usage_ fields that I’m interested in are still not shown in this case (yet are still sent to influxdb when I run the service proper).

If anyone has any clues on why the test doesn’t show the actual fields sent, I’d be very grateful! :slight_smile:

Maybe you are testing against a config file that is not the same that the service uses?

I don’t know the details of your platform but in debian to test against the same config file that the service uses you must enter

telegraf -test -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d/

Calculating the cpu usage requires two collections, but -test only performs one in version 1.2.1. In the next release we do a second collection on this plugin, and -test will be able to display usage.

Thanks both. I was definitely using the correct config, but it looks like this is a side-effect of the need for two collections (to get a delta in time spent, to calculate usage, I assume). It’s reassuring to know that it wasn’t me doing something wrong. :slight_smile: