Params get encoded

Hi Prometheus Team
I want to know if i can prevent Prometheus from encoding the characters
scrape_configs:

  • job_name: ‘somename’
    params:
    prefix: [‘finatra’]
    url: [‘http://:9090/admin/metrics.json’]

When i do that,i get params encoded:
url=http%3A%2F%2F%3A9090%2Fadmin%2Fmetrics.json

Is there any idea?
Thanks

Hi LianYi,

The metrics path encoding can be avoided by using the metrics_path option in the job.

The HTTP resource path on which to fetch metrics from targets.

[ metrics_path: | default = /metrics ]

Reference:

Example:

  • job_name: ‘somename’
    metrics_path: /admin/metrics.json
    scrape_interval: 20s
    static_configs:
    • targets: [<target_ip_address>:80’]

I am not familiar with avoiding encoding of the general params. Good question.

Thanks a lot for your reply
just like your configurations:

  • job_name: ‘somename’
    metrics_path: /admin/metrics.json
    scrape_interval: 20s
    static_configs:
    * targets: [‘10.56.1.28:80’]

the url is 10.56.1.28:80/admin/metrics.json


then i want to get some params, so i configure like this :

  • job_name: ‘somename’
    metrics_path: /admin/metrics.json?url=http://1.1.1.1:9990/admin/metrics.json
    scrape_interval: 20s
    static_configs:
    * targets: [‘10.56.1.28:80’]

what i want is: 10.56.1.28:80/admin/metrics.json?url=http://1.1.1.1:9990/admin/metrics.json
when i captured the packets from tcpdump,the url was encoded like this:
10.56.1.28:80/admin/metrics.json%3Furl=http%3A%2F%2F%1.1.1.1%3A9990/admin/metrics.json


then i got an answer from stackoverflow:https://stackoverflow.com/questions/40172415/question-mark-in-prometheus-metrics-path-gets-encoded
like the issue,i can’t get the correct url what i want yet!

What is an example of a working URL? That should help convert to a Prometheus config.

the working url what i want is:
10.56.1.28:80/admin/metrics.json?url=http://1.1.1.1:9990/admin/metrics.json
but i got:
10.56.1.28:80/admin/metrics.json%3Furl=http%3A%2F%2F%1.1.1.1%3A9990/admin/metrics.json
just like a ‘Get’ mode http request,but some parameters got encoded
also some reserved characters in RFC3986,like “?” ,":","/"

The above might be closer but it looks like the “?” sign still gets encoded for the browser to handle it.

prometheus_somename_parser_URL_encoded

When the “endpoint” URL is clicked I see the URL as:
http://10.56.1.28/admin/metrics.json%3Furl=http://1.1.1.1:9990/admin/metrics.json

I found this relating to the question mark:

Also this is interesting:

https://www.debugcn.com/en/article/15572338.html

Thanks a lot for your help
As a result,we can not write these to metrics_path
so need to use params configuration?
https://stackoverflow.com/questions/40172415/question-mark-in-prometheus-metrics-path-gets-encoded

looks well at this time
image

But when I click the “Endpoint” URL,I get
http://10.56.1.28/metrics?prefix=finatra&url=http%3A%2F%2F1.1.1.1%3A9090%2Fadmin%2Fmetrics.json

of course, this is not what I want And will give rise to requesting false

Looks like Prometheus “URL Encodes” the metrics_path parameter URL by design.

This video says “do not encode the whole URL”.

My opinion is there should be an option to “Not URL encode” the metrics_path at all.

I guess we have to hope someone else provides some feedback.

What happens when you click on the Prometheus target link? Does the target show any logs?

I agree with you

When I click on the target link, I get 404 because of the error URL

So I test all the characters mentioned by RFC 3986:
metrics_path : :/?#[]@ !$&`()*+,;= -._~

And I get:

image

Maybe they are right And the working of decoding URL must do by the server

1 Like