Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question mark in Prometheus metrics_path gets encoded

Tags:

prometheus

Because Prometheus only supports text metrics and many tool return metrics in json (like Finatra, Spring Boot), I created a simple proxy which translates the json into text. Because I want to use it for multiple sources, the target from which the actual metrics are to be retrieved is set via a query param.

The metrics url looks like this:

/metrics?prefix=finatra&url=http://<ip>:9990/admin/metrics.json

This works fine in a browser or curl. However, in Prometheus the '?' gets encoded to '%3F' and therefore the request fails:

/metrics%3Fprefix=finatra&url=http://<ip>:9990/admin/metrics.json

How can I prevent Prometheus from encoding the ?? Is this a bug in Prometheus? I already tried escaping with % or \, using unicode etc, but still no luck.

like image 462
Joost den Boer Avatar asked Oct 21 '16 09:10

Joost den Boer


1 Answers

This behaviour is correct, as the metrics path is a path - not an arbitrary suffix on the protocol, host and port.

You're looking for the params configuration option:

scrape_configs:
  - job_name: 'somename'
    params:
      prefix: ['finatra']
      url: ['http://:9090/admin/metrics.json']
like image 97
brian-brazil Avatar answered Oct 27 '22 22:10

brian-brazil