Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: win_perf_counters not gathering non-English metrics #1730

Closed
PierreBart opened this issue Sep 8, 2016 · 20 comments
Closed

Windows: win_perf_counters not gathering non-English metrics #1730

PierreBart opened this issue Sep 8, 2016 · 20 comments
Labels
bug unexpected problem or unintended behavior help wanted Request for community participation, code, contribution platform/windows
Milestone

Comments

@PierreBart
Copy link

PierreBart commented Sep 8, 2016

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 ?

@sparrc
Copy link
Contributor

sparrc commented Sep 8, 2016

@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 😖 🙈

@PierreBart
Copy link
Author

PierreBart commented Sep 8, 2016

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.

@sparrc sparrc changed the title Windows: win_perf_counters send no metrics Windows: win_perf_counters not gathering French metrics Sep 8, 2016
@sparrc sparrc added bug unexpected problem or unintended behavior help wanted Request for community participation, code, contribution platform/windows labels Sep 8, 2016
@WisniewskiP
Copy link

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

@sparrc sparrc changed the title Windows: win_perf_counters not gathering French metrics Windows: win_perf_counters not gathering non-English metrics Sep 12, 2016
@PierreBart
Copy link
Author

PierreBart commented Sep 12, 2016

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

@vsavornin
Copy link

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

@nhaugo nhaugo added this to the Future Milestone milestone Sep 15, 2016
@Da1den
Copy link
Contributor

Da1den commented Sep 16, 2016

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.

@skonet
Copy link

skonet commented Oct 14, 2016

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.

@hahnjo
Copy link
Contributor

hahnjo commented Oct 21, 2016

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()!
(

var exists uint32 = win.PdhValidatePath(query)
)

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!

@sparrc sparrc modified the milestones: 1.2.0, Future Milestone Oct 22, 2016
@adeleglise
Copy link

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 ?

@sparrc
Copy link
Contributor

sparrc commented Oct 25, 2016

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.

@adeleglise
Copy link

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.

@0x000flo
Copy link

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 = "% Gastausführungszeit"

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

Tell me if you need more input.

@Da1den
Copy link
Contributor

Da1den commented Oct 25, 2016

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.

@0x000flo
Copy link

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!

@adeleglise
Copy link

The metrics are indeed collected with PreVistaSupport set to true.

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

@dgnorton
Copy link
Contributor

Are quotes in the names a separate issue?

@vsavornin
Copy link

vsavornin commented Oct 26, 2016

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.

@adeleglise
Copy link

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

@sparrc
Copy link
Contributor

sparrc commented Dec 13, 2016

closed by #1944

@sparrc sparrc closed this as completed Dec 13, 2016
@PierreF
Copy link
Contributor

PierreF commented Jan 12, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior help wanted Request for community participation, code, contribution platform/windows
Projects
None yet
Development

No branches or pull requests