Telegraf: Windows: win_perf_counters not gathering non-English metrics

Created on 8 Sep 2016  路  20Comments  路  Source: influxdata/telegraf

EDIT Oct 25 WORKAROUND: set PreVistaSupport = true in your config file

Hello,

  • OS: Windows 10
  • Telegraf: 1.0.0 Windows

I'm trying to gather metrics using the Windows Performance Counters plugin.

_Problem:_ no metrics are sent to my influxdb server.

My Config file:

[[inputs.win_perf_counters]]
PrintValid=true
  [[inputs.win_perf_counters.object]]
    ObjectName = "Processeur"
    Instances = ["*"]
    Counters = ["% temps processeur", "Interruptions/s", "% temps utilisateur"]
    Measurement = "win_cpu"
    FailOnMissing= true

I precise i'm on a French system so I had to look for the translated Counters' name and path using PowerShell.

Here are the print in debug mode:

2016/09/08 16:02:05 Attempting connection to output: influxdb
2016/09/08 16:02:05 Successfully connected to output: influxdb
2016/09/08 16:02:05 Starting Telegraf (version 1.0.0-rc1)
2016/09/08 16:02:05 Loaded outputs: influxdb
2016/09/08 16:02:05 Loaded inputs: win_perf_counters
2016/09/08 16:02:05 Tags enabled: host=HOST
2016/09/08 16:02:05 Agent Config: Interval:10s, Debug:true, Quiet:false, Hostname:"HOST", Flush Interval:10s
Valid: \Processeur(*)\% temps processeur
Valid: \Processeur(*)\Interruptions/s
Valid: \Processeur(*)\% temps utilisateur
2016/09/08 16:02:10 Input [win_perf_counters] gathered metrics, (10s interval) in 546.8525ms
2016/09/08 16:02:20 Input [win_perf_counters] gathered metrics, (10s interval) in 0
2016/09/08 16:02:20 Output [influxdb] buffer fullness: 0 / 1000 metrics. Total gathered metrics: 0. Total dropped metrics: 0.
2016/09/08 16:02:30 Input [win_perf_counters] gathered metrics, (10s interval) in 0
2016/09/08 16:02:30 Output [influxdb] buffer fullness: 0 / 1000 metrics. Total gathered metrics: 0. Total dropped metrics: 0.
....
2016/09/08 16:04:00 Input [win_perf_counters] gathered metrics, (10s interval) in 0
2016/09/08 16:04:00 Output [influxdb] buffer fullness: 0 / 1000 metrics. Total gathered metrics: 0. Total dropped metrics: 0.

Any ideas ?

bug help wanted platforwindows

All 20 comments

@Pibeurthss can you try running a test output of telegraf? I'm sorry but I don't have the resources to test windows problems specific to French systems.....I would be surprised that windows would rename the metrics, but there isn't much Microsoft can do that surprises me anymore 馃槚 馃檲

telegraf -config telegraf.conf -test
* Plugin: win_perf_counters, Collection 1
Valid: \Processeur(*)\% temps processeur
Valid: \Processeur(*)\Interruptions/s
Valid: \Processeur(*)\% temps utilisateur

It seems there is no metrics...

I precise that System Inputs work normally and I can gather them.

I have the same problem on German version of Windows.

telegraf.exe -config telegraf.conf -test
* Plugin: win_perf_counters, Collection 1
Valid: \Prozessor(*)\Leerlaufzeit (%)
Valid: \Prozessor(*)\Interruptzeit (%)
Valid: \Prozessor(*)\Privilegierte Zeit (%)
Valid: \Prozessor(*)\Benutzerzeit (%)
Valid: \Prozessor(*)\Prozessorzeit (%)

I think it will be problem with all version other than English

I think so.
I have agents installed on English System and it works perfectly!

Hello,

  • OS: Windows 7 64 bits (localized in french)
  • Telegraf: 1.0.0 Windows

I'm trying to gather metrics using the Windows Performance Counters plugin on a Windows 7 64bits localized in French.

Problem: the inputs plugin don't extract counters with a quote.

My Config file:

[[inputs.win_perf_counters]]

  PreVistaSupport=false
  PrintValid=true

 [[inputs.win_perf_counters.object]]
    # Processor usage, alternative to native, reports on a per core.
    ObjectName = "Processeur"
    Instances = ["*"]
    Counters = ["% d'inactivit茅", "% temps d'interruption", "% temps privil茅gi茅", "% temps utilisateur", "% temps processeur"]
    Measurement = "win_cpu"
    #IncludeTotal=false #Set to true to include _Total instance when querying for all (*).

I precise i'm on a French system so I had to look for the translated Counters' name and path using PowerShell.

Here is the ouput with the test option :

PS D:\telegraf> .\telegraf.exe --config D:\telegraf\telegraf_win.fr.conf --test
* Plugin: win_perf_counters, Collection 1
Valid: \Processeur(*)\% temps privil茅gi茅
Valid: \Processeur(*)\% temps utilisateur
Valid: \Processeur(*)\% temps processeur

Only 3 of 5 counters wanted are listed.
The missing 2 counters have a quote into their name :

  • "% d'inactivit茅"
  • "% temps d'interruption"

Please note that many counters in French have a quote in their name.

You may analyze further with the complete extract of my localized perf counters with the file attached :
Win7_FR_Perf_Counters.txt

Regards

Hello,

I ran into the same problem today with:

  • Windows 7 (64-bit) localized in Germany
  • Telegraf 1.0.0

My config file:

[[inputs.win_perf_counters]]
  PrintValid=true
 [[inputs.win_perf_counters.object]]
    # Processor usage, alternative to native, reports on a per core.
    ObjectName = "Prozessor"
    Instances = ["*"]
    Counters = ["Prozessorzeit (%)"]
    Measurement = "win_cpu"

If i executed telegraf with this config, telegraf confirmed the counter as valid with:

Valid: \Prozessor(*)\Prozessorzeit (%)

but no metric was gathered.

I looked into the go code of the win_perf_counters (https://github.com/influxdata/telegraf/blob/master/plugins/inputs/win_perf_counters/win_perf_counters.go) and modified following section:

if m.PreVistaSupport {
        ret = win.PdhAddCounter(handle, query, 0, &counterHandle)
} else {
        ret = win.PdhAddEnglishCounter(handle, query, 0, &counterHandle)
}

I changed it to:
ret = win.PdhAddCounter(handle, query, 0, &counterHandle)

I think the PdhAddEnglishCounter function doesn't provide a language-neutral way to add performance counters to the query or there are other restrictions that come up.
I don't know why it don't work but after I edited it, build it and run it, metrics were created and I could gather data.
I tested it with a few counters and only in german but I think it is a good start for further investigations.

Best Regards.

Hello,

Same problem here... such a pity that all "Windows counters collection" implementations face the same issues with non-English counters...

Thanks to fix this!
Best regards.

I also stumbled across this one on a German server.

As the code snippet above shows, you can set PreVistaSupport = true in your config which will take the other branch and everything is fine.

When you try to use the English name on a localized system, validation won't let your query be passed to PdhAddCounter: There is no PdhValidateEnglishPath()!
(https://github.com/influxdata/telegraf/blob/abcd19493e1d8c940cbbb5c87f05ce92d44e8e8e/plugins/inputs/win_perf_counters/win_perf_counters.go#L196)

So I would suggest to remove PreVistaSupport and let it default to true: Only English systems will work with it being false and they can use the non-localized names anyway!

Hi,

I'm facing this issue on a Windows 2012 R2 Server, with telegraf 1.0.1. The system is localized in french, and not metrics are forwarded to influxdb.

How can we give an help in hand with this issue ?

we will try to have this fixed in release 1.2, if anyone can submit a PR it would be helpful.

FWIW, there is quite an easy workaround, just set PreVistaSupport = true. Please let us know if this workaround is not working for you.

With the PreVistaSupport parameter set to true, the metrics are collected. Thanks.

Tell me if I can do anything to help you with feedback from my tests.

Hi,

I can confirm that PreVistaSupport is working but there are counters with special chars (umlauts) which are not being processed. (Total gathered metrics: 0. Total dropped metrics: 0.)
Example:
ObjectName = "Virtueller Prozessor des Hyper-V-Hypervisorstamms"
Counters = "% Gastausfhrungszeit"

Maybe this could be also adressed in release 1.2...

Tell me if you need more input.

Hi,
@0x000flo I just took a look on your problem but first I could not find the ObjectName "Virtueller Prozessor des Hyper-V-Hypervisorstamms" so I could not recreate your scenario but I tried another counter with special chars (umlaut).
Example:

[[inputs.win_perf_counters.object]]
ObjectName= "Arbeitsspeicher"
Counter = ["Verf眉gbare Bytes"]
Instances = ["------"]
Measurement = "win_mem"

I tried another one as well and that worked, too.

So I do not know what is wrong but I think that the win perf counters can handle special chars.
Otherwise it would be pretty sad because Microsoft localized them and created this mess.

Maybe you can try the win pref counter in my example and analyze if it is working on your system and if it is working you can try the Hyper-V again.

Maybe your config-file is wrong at one point.

Best regards.

Hi @Da1den,

Thanks for looking into it.
My example was a bit odd. This counter is only available when the Hyper-V server role is installed.
I found my mistake. I edited the .conf file directly on the server and opened it with wordpad >< So the encoding was messed up. As I was looking on your example I used Notepad with utf8 encoding and everything is working now.

Thank you all!

The metrics are indeed collected with PreVistaSupport set to true.

But counters with quotes in their names are still not collected.

Are quotes in the names a separate issue?

Hi !

Found the solution for the quotes.
Windows doesn't use the classic quote, but the curly one (cf. explanations here)

You can use curly quote with ALT+0146.

In config file, you need to replace all the quotes with curly quotes into the names of Perf Counters.

Tested with Telegraf v1.0.0 on Windows Localized in French
PreVistaSupport has to be set to True.

@vsavornin This solution works for me. Thanks for sharing.

Just to clarify situation: Windows localize the metrics. On non-English Windows, with PreVistaSupport = false it not possible to gather metrics. With PreVistaSupport = true it is possible to gather metrics if configuration use localized name.

This is an issue as it's not possible to have a generic configuration file that gather CPU... as processor need to be named "Processor", "Processeur", "Prozessor"...

For details of the cause, it's due to the way telegraf add the counter:

  • First is use PdhValidatePath to check if counter exist with that name. PdhValidatePath expect a localized name, thus on a French Windows, only "Processeur" will get accepted
  • Then, if PreVistaSupport = false, it add metric using PdhAddEnglishCounter which expect English name... but since PdhValidatePath only accept localized name, it will always fail for non-English Windows.
  • With PreVistaSupport = true, it add the metric using PdhAddCounter which expect localized name like PdhValidatePath

I think we should use English name (or at very least offer an option to support English name) instead of localized name. Having to localize the Telegraf configuration for all language seems too complicated :(

Sadly this probably means do no validate path (I didn't find any PdhValidatePathEnglish). I will try to come with a PR that don't use PdhValidatePath and see if we could validate path with another way.

Was this page helpful?
0 / 5 - 0 ratings