# Params get encoded

**URL:** <https://discuss.prometheus.io/t/params-get-encoded/390>\
**Category:** General Help/Support\
**Created:** [July 19, 2021, 12:58am UTC](https://discuss.prometheus.io/t/params-get-encoded/390 "2021-07-19T00:58:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LianYi](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@LianYi](https://discuss.prometheus.io/u/LianYi)\
**Post date:** [July 19, 2021, 12:58am UTC](https://discuss.prometheus.io/t/params-get-encoded/390/1 "2021-07-19T00:58:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tony\_casanova\_rtp\_nc](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@tony\_casanova\_rtp\_nc](https://discuss.prometheus.io/u/tony_casanova_rtp_nc)\
**Post date:** [July 25, 2021, 8:01pm UTC](https://discuss.prometheus.io/t/params-get-encoded/390/2 "2021-07-25T20:01:53Z")

</div>

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:

> **[Configuration | Prometheus](https://prometheus.io/docs/prometheus/latest/configuration/configuration/)**
>
> Prometheus project documentation for Configuration

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.

---

<div class="post-metadata">

**Author:** ![LianYi](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@LianYi](https://discuss.prometheus.io/u/LianYi)\
**Post date:** [July 26, 2021, 1:15am UTC](https://discuss.prometheus.io/t/params-get-encoded/390/3 "2021-07-26T01:15:03Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![tony\_casanova\_rtp\_nc](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@tony\_casanova\_rtp\_nc](https://discuss.prometheus.io/u/tony_casanova_rtp_nc)\
**Post date:** [July 26, 2021, 1:36am UTC](https://discuss.prometheus.io/t/params-get-encoded/390/4 "2021-07-26T01:36:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LianYi](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@LianYi](https://discuss.prometheus.io/u/LianYi)\
**Post date:** [July 26, 2021, 2:04am UTC](https://discuss.prometheus.io/t/params-get-encoded/390/5 "2021-07-26T02:04:57Z")

</div>

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 “?” ,":","/"

---

<div class="post-metadata">

**Author:** ![tony\_casanova\_rtp\_nc](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@tony\_casanova\_rtp\_nc](https://discuss.prometheus.io/u/tony_casanova_rtp_nc)\
**Post date:** [July 26, 2021, 12:59pm UTC](https://discuss.prometheus.io/t/params-get-encoded/390/6 "2021-07-26T12:59:38Z")

</div>

![prometheus_config_example](https://europe1.discourse-cdn.com/flex017/uploads/prometheus/original/1X/739eb8e69dc5555b23e13d656c738db9ca3c2059.png)

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](https://europe1.discourse-cdn.com/flex017/uploads/prometheus/original/1X/cca8cf05fa4674a9234c47051db7242d26ce5a0f.png)

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](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:

> <https://stackoverflow.com/questions/60935664/prometheus-metrics-path-gets-encoded>

> <https://github.com/prometheus/prometheus/issues/5488>
>
> Hello All,
> 
> We are trying to scrape targets using urls like following:
> 
> http…://example.com:1234/service/metrics?&b1234
> 
> sample config:
> 
> \`\`\`
> \- job\_name: test-1
> metrics\_path: /service/metrics?&b1234
> scheme: http
> static\_configs:
> - targets:
> - example.com:1234
> \`\`\`
> 
> Here example.com is a VIP url which load balances across multiple JVMs. In order to connect to a specific JVM, an affinity url is constructed using "&b1234". The load balancer uses this to identify which JVM to connect.
> However, Prometheus converts "?" to "%3F" while scraping and as a result gets 404.
> Can you help us in identifying a solution for this. I tried using params, but it needs a key, value structure.
> 
> Note: Due to security reasons, we cannot directly connect to the individual JVM ports.

Also this is interesting:

[https://www.debugcn.com/en/article/15572338.html](https://www.debugcn.com/en/article/15572338.html)

---

<div class="post-metadata">

**Author:** ![LianYi](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@LianYi](https://discuss.prometheus.io/u/LianYi)\
**Post date:** [July 27, 2021, 2:27am UTC](https://discuss.prometheus.io/t/params-get-encoded/390/7 "2021-07-27T02:27:22Z")

</div>

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](https://stackoverflow.com/questions/40172415/question-mark-in-prometheus-metrics-path-gets-encoded)

looks well at this time  
 ![image](https://europe1.discourse-cdn.com/flex017/uploads/prometheus/original/1X/af07a5c07b4b43ee2f6821477f7ce24dece0c5a6.png)

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](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

---

<div class="post-metadata">

**Author:** ![tony\_casanova\_rtp\_nc](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@tony\_casanova\_rtp\_nc](https://discuss.prometheus.io/u/tony_casanova_rtp_nc)\
**Post date:** [July 27, 2021, 1:58pm UTC](https://discuss.prometheus.io/t/params-get-encoded/390/8 "2021-07-27T13:58:32Z")

</div>

Looks like Prometheus “URL Encodes” the metrics\_path parameter URL by design.

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

[![](https://europe1.discourse-cdn.com/flex017/uploads/prometheus/original/1X/b50c71d0dda42de1693f6b1e02de67cd32e992b1.jpeg "What is URL Encoding? - URL Encode/Decode Explained - Web Development Tutorial") ](https://www.youtube.com/watch?v=lkAeX3T6A9I)

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?

---

<div class="post-metadata">

**Author:** ![LianYi](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@LianYi](https://discuss.prometheus.io/u/LianYi)\
**Post date:** [July 28, 2021, 7:03am UTC](https://discuss.prometheus.io/t/params-get-encoded/390/9 "2021-07-28T07:03:40Z")

</div>

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](https://europe1.discourse-cdn.com/flex017/uploads/prometheus/original/1X/7f2c3b073d368aa631b526fb1f7c5cc38a24d99a.png)

---

<div class="post-metadata">

**Author:** ![LianYi](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@LianYi](https://discuss.prometheus.io/u/LianYi)\
**Post date:** [July 28, 2021, 8:12am UTC](https://discuss.prometheus.io/t/params-get-encoded/390/10 "2021-07-28T08:12:20Z")

</div>

[![image](https://europe1.discourse-cdn.com/flex017/uploads/prometheus/original/1X/cf47dd3eedf532c62c0ec0adfe62d0a61b28196f.png)](https://www.ietf.org/rfc/rfc3986.txt)

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