Pushgateway windows

From UVOO Tech Wiki
Revision as of 01:48, 12 January 2024 by Busk (talk | contribs)
Jump to navigation Jump to search

Windows

Not working

$ErrorActionPreference = "Stop"
$hname = (hostname)
$user = "myuser"
$pass = "mypass"
$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($user, $secpasswd)
$r=(invoke-webrequest http://localhost:9182/metrics)
$metrics = ($r.content.tostring())
Invoke-WebRequest -uri https://pushgateway.example.com/metrics/job/node-windows/instance/$hname -cred $cred -Body $metrics -Method Post

No working

$ErrorActionPreference = "Stop"
$r=(invoke-webrequest http://localhost:9182/metrics)
# $metrics = ($r.tostring() -split "[`r`n]" | select-string -pattern "go_|http_request|http_requests|http_response|process" -NotMatch)
$metrics = ($r.content.tostring() -split "[`r`n]" | select-string -pattern "go_|http_request|http_requests|http_response|process" -NotMatch)
# $metrics = ($metrics -replace '(?m)^\s*?\n'| out-string )
$metrics = ($metrics -replace '(?m)^\s*?\n')
# echo $metrics | more
# $metrics = ($r.tostring())
Invoke-WebRequest -uri https://example.uvoo.io/metrics/job/windows-nodes/instance/winhost -cred $cred -Body $metrics -Method Post