Posted On May 13, 2022

How To Modify Collectors of Windows Exporter

kimconnect 0 comments
blog.KimConnect.com >> Codes >> How To Modify Collectors of Windows Exporter

Update: here’s a generalized version of this function that can be applied to other services

The follow cmdlets assumes that Prometheus Windows Exporter has already been installed. This is how to modify an existing instance:

# Example: Enabling Collectors for a Hyper-V Server
$serviceName='Windows_Exporter'
$enabledCollectors='os,cpu,cs,logical_disk,net,tcp,hyperv,service,textfile'
$wmiService=Get-WmiObject win32_service| ?{$_.Name -like "*$serviceName*"}
$exePath=[regex]::match($wmiService.PathName,'\"(.*)\"').groups[1]
$binaryPath = '\"' + $exePath + '\"' + " --log.format logger:eventlog?name=windows_exporter --collectors.enabled $enabledCollectors"
sc.exe config $serviceName binpath= $binaryPath
sc.exe qc windows_exporter
restart-service $serviceName

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: List All IPs Used by Cluster

Snippet: # Obtain IPs of resources in clusterfunction getResourceIPs { $resourceIPs=Get-Cluster | Get-ClusterResource | ?{$_.ResourceType…

Restore User Script

echo offSET RAR="C:\Program Files\WinRAR\RAR.EXE"IF NOT EXIST P:\ (NET USE P: \\WDFS1\BACKUP)cd %USERPROFILE%%RAR% x -y p:\%username%\desktopstuff.rarC:cd…

Recommended Skill Set of a Programmer

It's a given that a coder needs to learn how to code... like really well.…