Telegraf: Windows: multiple config files not working properly

Created on 2 May 2016  路  14Comments  路  Source: influxdata/telegraf

Hi,

I've stared using "win_perf_counters" on Windows servers.
I have a little issue: I can not have multiple [[inputs.win_perf_counters]] in multiple files to arrange configs. For example, one for CPU, one for memory, etc...
It seems, only the first [[inputs.win_perf_counters]] found in my telegraf.d directory is used.

WIth snmp input, I can have multiple [[inputs.snmp]], one per file per switch.

Is it an expected behavior ?

I need a such feature for managing config with Puppet.

arewindows bug help wanted platforwindows

Most helpful comment

Would love to get this feature. For configuration management for large environments then you could have one base telegraf config that all machines get and then one extra file per role, for SQL servers, for IIS servers and so on.

All 14 comments

that's not expected.....can you post the config files that you're using? Both the main and any you have in directories.

Here is the "main" config file:

[global_tags]
    os = "windows"

[agent]
    interval = "30s"
    collection_jitter = "5s"
    flush_interval = "30s"
    metric_buffer_limit = 5000
    round_interval = false
    flush_jitter = "10s"
    flush_buffer_when_full = true
    debug = false
    quiet = false

[[outputs.influxdb]]
    urls = ["http://influxdbdev1.odiso.net:8086"]
    database = "telegraf"
    precision = "s"

All files in telegraf.d, one input per file.

win_perf_counters_logicaldisk.conf

[[inputs.win_perf_counters]]

    [[inputs.win_perf_counters.object]]
        ObjectName = "LogicalDisk"
        Instances = ["*"]
        Counters = ["% Disk Read Time", "% Disk Time", "% Disk Write Time", "% Free Space", "% Idle Time", "Disk Reads/sec", "Disk Writes/sec", "Free Megabytes"]
        Measurement = "win_logicaldisk"
        IncludeTotal=false

win_perf_counters_memory.conf

[[inputs.win_perf_counters]]

    [[inputs.win_perf_counters.object]]
        ObjectName = "Memory"
        Counters = ["Available Bytes", "Cache Bytes"]
        Instances = ["------"]
        Measurement = "win_memory"
        IncludeTotal=false

win_perf_counters_network_interface.conf

[[inputs.win_perf_counters]]

    [[inputs.win_perf_counters.object]]
        ObjectName = "Network Interface"
        Instances = ["*"]
        Counters = ["Bytes Received/sec", "Bytes Sent/sec", "Packets Received/sec", "Packets Sent/sec"]
        Measurement = "win_network_interface"
        IncludeTotal=false

win_perf_counters_processor.conf

[[inputs.win_perf_counters]]

    [[inputs.win_perf_counters.object]]
        ObjectName = "Processor"
        Instances = ["*"]
        Counters = ["% C1 time", "% C2 time", "% C3 time", "% DPC time", "% Idle Time", "% Interrupt Time", "% Privileged Time", "% User Time", "% Processor Time"]
        Measurement = "win_processor"
        IncludeTotal=true

win_perf_counters_system.conf

[[inputs.win_perf_counters]]

    [[inputs.win_perf_counters.object]]
        ObjectName = "System"
        Counters = ["Context Switches/sec", "System Calls/sec", "Threads", "Processes", "System Up Time"]
        Instances = ["------"]
        Measurement = "win_system"
        IncludeTotal=false

Only "processor" is working at the moment.

If I copy/paste everything in one file with only one line:

[[inputs.win_perf_counters]]

And then all block starting with:

    [[inputs.win_perf_counters.object]]

Everything is working.

Any update regarding this issue?

nope, you will need to use one file for now.

Would love to get this feature. For configuration management for large environments then you could have one base telegraf config that all machines get and then one extra file per role, for SQL servers, for IIS servers and so on.

Hello. Any chance to have news about this issues

This is a low priority for me at the moment, there is an easy workaround and I don't have a way to easily reproduce as I don't have a windows dev environment. If someone can submit a PR it would be greatly appreciated.

I've identified the problem here while investigating another issue, we should use filepath.Walk in the config.LoadDirectory function instead of constructing the full path ourselves.

I am still seeing the behavior originally described in 1.2.0. @glz-io, is it working as expected for you?

My windows servers are not on the latest version at the moment. I'll try to work on this by the end of the week.

When I attempt to load multiple files with [[inputs.win_perf_counters]] I see it listed multiple times in the telegraf.log.

Example: With [[inputs.win_perf_counters]] defined in three files I see.
I! Loaded inputs: inputs.win_perf_counters inputs.win_perf_counters inputs.win_perf_counters

@sparrc I believe this issue was prematurely closed - the problem still exists as of the latest nightly. Like @cdhunt mentioned, the log lists multiple inputs being loaded but only one actually collects.

If anyone wants to take a stab at this it is probably related to these package level variables: https://github.com/influxdata/telegraf/blob/master/plugins/inputs/win_perf_counters/win_perf_counters.go#L69

Thanks for the guidance @danielnelson, I'll take a shot at this.

Was this page helpful?
0 / 5 - 0 ratings