'Postman to prometheus and carriage "\r"?. text format parsing error in line 1: expected float as value, got "1\r"

Just trying to add new metric to Prometheus through the Postman, but getting

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

Metric just like

"test_metric 1
"

(without quotes)

Why it happens and how can i remove it from postman's request?



Solution 1:[1]

The reason is in difference between \r and \n, so i found workaround using Pre-request script, so just open this tab in Postman and add :

pm.request.body.update(pm.request.body.raw.replace(/\r/g, ''))

It will remove all \r from you body. And don't forget to leave new line in body as prometheus need it for metric

enter image description here enter image description here

Solution 2:[2]

The Postman pre-request script cannot change pm.request.body. In stead you can specify a {{body}} variable, and set it using the pre-request script.

var body = your body text.replace(/\r/g, '');

pm.variables.set('body', body);

See: https://github.com/postmanlabs/postman-app-support/issues/9020

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nigrimmist
Solution 2 Lovbjerg