i have configured pushgateway which is up and running. I have windows server i have configured script which would count rest api numbers from log (just 4 digit numbers) and save it in text file. I wanted to send this metric to pushgateway so that i can get grafana dashboard created from prometheus as database. I am getting error, what am i missing. $number=1234
first method
$number = Get-Content -Path "C:\path\to\your\numberfile.txt" -Raw
$metricString = "custom_metric $number 1"
echo "$metricString" `r`n | Invoke-WebRequest -Uri "http://localhost:9091/metrics/job/your_job" -Method Post
---------------------------------------------------------
second method
$number = Get-Content -Path "C:\path\to\your\numberfile.txt" -Raw
$metricString = "custom_metric $number 1"
# Send the metric string via Invoke-WebRequest
$metricString | Invoke-WebRequest -Uri "http://localhost:9091/metrics/job/your_job" -Method Post
when i run this i get error "text format parsing error in line 1, i found this informative command on other issue,
Send metrics with pushgateway (Prometheus) using windows console
my query is if i want to run that command echo then invoke how would i do this, when i try to run echo command then hit shift+ enter go to new line then run | invoke command i am able to send test metric to pushgateway. how would i do this via script
tried adding 'n' or 'r''n etc to getinto new line still now luck can some one please help
also how do i send instance Ip while sending alert??
provide more updates above
Prometheus pushgateway accepts metrics in the following format:
Where:
metric_nameis the name of the metric. For example,temperatureorrequests_total{optional_labels}is optional labels for the given metric. For example, {path="/foo",method="POST"}`meteic_valueis numeric value for the metric. For example,123.456.A single request to pushgateway can contain multiple metrics. They must be delimited by newline aka
\nchar. For example:Note also that pushgateway doesn't store all the pushed values for the same time series - it just keeps the last pushed sample and returns it to Prometheus when it scrapes the pushgateway. If you want storing all the samples, then try using /api/v1/import/prometheus endpoint at VictoriaMetrics - this is Prometheus-like monitoring solution I work on.
P.S. See these docs for details on Prometheus data model and key concepts.