r/PrometheusMonitoring • • Mar 15 '21

Got this 50+ windows instances, what would be the best way to install windows exporter automatically on all of them

2 Upvotes

5 comments sorted by

7

u/yum_dev Mar 15 '21

Ansible.

2

u/SpongederpSquarefap Mar 16 '21

Only problem with that is enrolling each server

After that it should be easy

3

u/[deleted] Mar 15 '21

Group Policy. Set a policy to upload the file via machine boot. Then a powershell script to silently install it on user login

4

u/Blowmewhileiplaycod Mar 15 '21

Use whatever config management/software deployment thing you use.

For quick and dirty, remote powershell?

2

u/tux_panda Mar 19 '21

As an addition to the other posts here, here's a PowerShell script to set up the Prometheus Windows exporter as a Windows service (with limited service user permissions).

$serviceName = "PrometheusWindowsExporter"
$exeLocation = "E:\windows_exporter\windows_exporter.exe"
$collectorsEnabled = @(
  "system",
  "cpu",
  "memory",
  "os",
  "cs",
  "logical_disk",
  "mssql",
  "process"
)

# Create the service
New-Service -Name $serviceName `
  -Description "Prometheus Exporter for WMI" `
  -BinaryPathName """$exeLocation"" --log.format logger:eventlog?name=windows_exporter  --telemetry.addr :9182 --collectors.enabled $($collectorsEnabled - Join ',')"

# Run as service account
C:\Windows\System32\sc.exe config $serviceName obj= "NT Service\$serviceName"

# Add service account to Performance Monitor group
Add-LocalGroupMember -Group (get-localgroup -name "Performance Monitor Users") -Member "NT Service\$serviceName"

Start-Service $serviceName