The title is pretty much my question - I'm new to Telegraf and slowly getting to grips with how to run it and specify log files, archiving processes, etc etc.
One of the, IMO very simple, tasks I have is to specify the metrics collected. For example, only to collect CPU-busy per CPU ID. But when I run my basic config (telegraf --config telegraf.conf --once), it collects literally every field per the input requested.
Is there a way to tell Telegraf to only collect specific fields per the input? My Telegraf.conf CPU setup is as below:
[[inputs.cpu]]
percpu = false
totalcpu = true
collect_cpu_time = false
report_active = false
core_tags = false
Cheers very much in advance, Vinny
Telegraf configuration provides support for metric-filtering. For your use case, you may try fieldpass or fielddrop whichever is useful.
Short description about:
fieldpass: An array of glob pattern strings. Only fields whose field key matches a pattern in this list are emitted.
fielddrop: The inverse of fieldpass. Fields with a field key matching one of the patterns will be discarded from the point.
I assume that by cpu busy, you mean the percentage consumption by user level processes. In that case, your configuration becomes:
[[inputs.cpu]]
percpu = false
totalcpu = true
collect_cpu_time = false
report_active = false
core_tags = false
fieldpass = ["usage_user"]
The above configuration will output only the usage by user level processes.
NOTE: By CPU busy, if you mean to collect system usage as well, add usage_system as well to the fieldpass array
If you would like to report the sum of all non-idle CPU states, you need to set report_active = true
in the above configuration. To report only the active usage (sum of all non-idle CPU states), pass the usage_active
in the fieldpass array as fieldpass = ["usage_active"]
If you wish to collect statistics of each cpu separately, set percpu = true