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

Read configuration from file #233

Closed
petemounce opened this issue Jul 30, 2018 · 4 comments
Closed

Read configuration from file #233

petemounce opened this issue Jul 30, 2018 · 4 comments
Labels

Comments

@petemounce
Copy link

Would it be reasonable to extend this excellent app to let it read configuration from a file? I'm setting it up for the first time, running it via NSSM, and finding that the service declaration with various flags and per-process filters is quite long. My own is:

"C:\wmi_exporter\wmi_exporter.exe" --log.format logger:eventlog?name=wmi_exporter  --telemetry.addr :5000 --collectors.enabled "cpu,cs,logical_disk,net,os,service,system,textfile" --collector.service.services-where "Name='buildkite-agent'" --collector.service.services-where "Name='wmi_exporter'"

I was thinking along the lines of TOML via https://github.com/toml-lang/toml

listen_address = 9182

[log]
format = "eventlog"
name = "wmi_exporter" 

[collectors_enabled]

  [collectors_enabled.cpu]
  [collectors_enabled.cs]
  [collectors_enabled.logical_disk]
  [collectors_enabled.net]
  [collectors_enabled.os]
  [collectors_enabled.services]
    filters = [
      "Name='wmi_exporter'",
      "Name='something_else'",
    ]
  [collectors_enabled.process]
    filters = [
      "Name='firefox%'",
      "Name='something_else%'",
    ]
  [collectors_enabled.service]
  [collectors_enabled.system]
  [collectors_enabled.textfile]
    directory = "c:/wmi_exporter/metrics_files"
@carlpett
Copy link
Collaborator

Hi @petemounce,
The general pattern amongst Prometheus exporters is to prefer flags to files, where possible. Is this problematic for you due to doing manual installations, or do you have some other use-case?

As a side-note, why are you running under nssm? The exporter supports running as a service natively, so you don't have to (but you might have some other reasons such as uniformity of deployment with other services?).
Also, you could cut down on your command line length by skipping the --collectors.enabled, since you are simply listing the defaults?
And finally, does listing --collector.service.services-where twice actually work? It would be a surprise to me if it does.

@petemounce
Copy link
Author

re: flags over file - ok.

re: nssm -

  • I didn't want to run as LOCALSYSTEM and didn't see a convenient way to change that via an installer parameter, so I reverted to downloading the zip and rolling my own.

    • This is my current user-creation - I'd love to trim away the Administrators group.
    add-type -AssemblyName System.web
    $password = [system.web.security.membership]::GeneratePassword(32,0)
    # /y to suppress the "longer than 14 characters" warning + interactive prompt
    & net user wmi_exporter $password /add /y
    # Apparently, all three groups are necessary to read performance counters / make WMI queries
    & net localgroup "Performance Monitor Users" wmi_exporter /add
    & net localgroup "Performance Log Users" wmi_exporter /add
    & net localgroup "Administrators" wmi_exporter /add
  • uniformity of deployment with my other services, as you say.

re: --collectors.enabled - I want to include the dns and tcp ones, probably, and maybe also the process ones. I'm setting up build slaves, so might want to be able to capture resource usage by different tools in different pipelines; not sure yet.

re: --collector.service.services-where twice - nope! :) Would you mind extending the readme to cover how to set up exporting of

  • more than one service-name? I tried
    • --collector.service.services-where "Name='wmi_exporter'" --collector.service.services-where "Name='other-service'"
    • --collector.service.services-where "Name='wmi_exporter' OR Name='other-service'"
      but neither worked :(
  • more than one process-name-pattern? Here, I didn't try, because I didn't succeed with my guesses above.

@carlpett
Copy link
Collaborator

Yep, since WMI requires such high privileges, it didn't seem to add much value to use a separate administrative service account. It wouldn't be a major change if there is a use-case, though.

Ok. If you want to keep the defaults turned on and just add a few more, you can use the [defaults] placeholder to not have to list them all (and also not have to keep up with the defaults as you update and we potentially add new default ones), so you'd have --collectors.enabled [defaults],tcp, for example.

It should work with the second one there, having a single argument with the patterns separated by OR... Odd. (And it is the exact same approach on the process collector, btw)

@petemounce
Copy link
Author

Yep, since WMI requires such high privileges, it didn't seem to add much value to use a separate administrative service account. It wouldn't be a major change if there is a use-case, though.

I naively started with "let's not give it LOCALSYSTEM or admin" and see if it works, then added the other two Performance* groups, then :table_flip: and gave it admin. Windows 🔫

re: [defaults] placeholder - ta, missed that.

re: query - neither worked, am confused. I'll try again, I might have tried while also changing the groups setup without realising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants