diff --git a/prometheus/Dockerfile b/prometheus/Dockerfile index 579824beb9..0db252762f 100644 --- a/prometheus/Dockerfile +++ b/prometheus/Dockerfile @@ -26,7 +26,7 @@ RUN \ chown -R prometheus:prometheus /prometheus && \ apk del .build-deps && \ pip3 install \ - requests==2.31.0 + httpx==0.24.1 COPY prometheus.yml /etc/prometheus/ COPY fetch_targets.py / diff --git a/prometheus/fetch_targets.py b/prometheus/fetch_targets.py index 06219173e6..56f06494d9 100644 --- a/prometheus/fetch_targets.py +++ b/prometheus/fetch_targets.py @@ -7,6 +7,7 @@ import sys import urllib.parse +import httpx async def async_main(logger, target_file, url, username, password): while True: @@ -17,7 +18,8 @@ async def async_main(logger, target_file, url, username, password): b"Authorization": b"Basic " + base64.b64encode(f"{username}:{password}".encode("ascii")) } - response = requests.get(url, headers=headers, stream=True) + async with httpx.AsyncClient() as client: + response = await client.get(url, headers=headers) response.raise_for_status() logger.debug("Code %s", response.status_code) raw_json = response.json()