-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request params not correctly passed to request.get in PrometheusConnect.custom_query #260
Comments
Hi @GiulioGx, thanks for opening the issue! Line 346 seems to be a comment, is this referring to line 355 instead? Anyway, I believe import requests
from requests.adapters import HTTPAdapter
url = 'https://prometheus.demo.do.prometheus.io'
session = requests.Session()
session.mount(url, HTTPAdapter(max_retries=3))
params = {'time': 1680746497}
response = session.get(
"{0}/api/v1/query".format(url),
params={**{"query": "ALERTS"}},
**params,
)
print(response.content) But the above gave me an error, so I had to replace the call to be like the current implementation params = {'time': 1680746497}
response = session.get(
"{0}/api/v1/query".format(url),
params={**{"query": "ALERTS"}, **params},
) which succeeded. Does this help clarify your issue or did I misunderstand your problem? |
Hi @chauhankaranraj, thanks for the quick reply! The above code does not work because time is not a parameter accepted by the request() method. (The original issue I had was in fact trying to change the timeout to the http request to the prom server) |
At line 346 of prometheus_connect.py we have:
response = self._session.get(
"{0}/api/v1/query".format(self.url),
params={**{"query": query}, **params},
verify=self.ssl_verification,
headers=self.headers,
)
the params dict, ultimately used to pass params (for instance timeouts) to the requests get method is not correctly passed.
It should be modified to:
response = self._session.get(
"{0}/api/v1/query".format(self.url),
params={**{"query": query}},
**params,
verify=self.ssl_verification,
headers=self.headers,
)
The text was updated successfully, but these errors were encountered: