Powershell POST to pushgateway

223 views
Skip to first unread message

Leen Tux

unread,
Mar 4, 2024, 2:10:18 AM3/4/24
to Prometheus Users
Hi
What is the powershell command equivalent to:
$ echo 'metricname1 101' | curl --data-binary @- http://localhost:9091/metrics/job/jobname1/instance/instancename1

Brian Candler

unread,
Mar 4, 2024, 8:21:22 AM3/4/24
to Prometheus Users

Leen Tux

unread,
Mar 5, 2024, 12:29:05 AM3/5/24
to Prometheus Users
I got this error :
Invoke-WebRequest -Uri 'http://192.168.1.111:9091/metrics/job/jobname1/instance/instancename1' -Method Post -Body 'metricname1 101' -ContentType 'application/octet-stream'
Invoke-WebRequest : text format parsing error in line 1: unexpected end of input stream

I am facing the same issue here:
https://stackoverflow.com/questions/68818211/send-metrics-with-pushgateway-prometheus-using-windows-console
But the solution mentioned did not work for me.

echo "metricname1 101
" | Invoke-WebRequest -Uri http://192.168.1.111:9091/metrics/job/jobname1 -Method POST

Invoke-WebRequest : text format parsing error in line 1: expected float as value,  got "101\r"

Brian Candler

unread,
Mar 5, 2024, 2:41:26 AM3/5/24
to Prometheus Users
got "101\r"

suggests that you're sending a Windows newline (.....\r\n) instead of a Unix newline (.....\n), and that pushgateway isn't happy with that.

I don't know if Windows supports some mechanism for inserting explicit control sequences, such as
-Body 'metricname1 101\n'
or
echo -ne 'metricname1 101\n'
Reply all
Reply to author
Forward
0 new messages