Difference between revisions of "Pushgateway windows"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
``` | ``` | ||
$ErrorActionPreference = "Stop" | $ErrorActionPreference = "Stop" | ||
− | $cred = | + | $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) | $r=(invoke-webrequest http://localhost:9182/metrics) | ||
$metrics = ($r.content.tostring()) | $metrics = ($r.content.tostring()) | ||
− | Invoke-WebRequest -uri https://pushgateway.example.com/metrics/job/windows | + | Invoke-WebRequest -uri https://pushgateway.example.com/metrics/job/node-windows/instance/$hname -cred $cred -Body $metrics -Method Post |
``` | ``` | ||
Revision as of 01:48, 12 January 2024
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