2

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?

Nigrimmist
  • 10,289
  • 4
  • 52
  • 53

2 Answers2

2

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

Nigrimmist
  • 10,289
  • 4
  • 52
  • 53
0

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

Lovbjerg
  • 1
  • 4