Skip to content

Commit

Permalink
metrics-pusher fetch metrics with extra session
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-oleynik committed Aug 6, 2024
1 parent 139fcb8 commit 1d68129
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion metrics-pusher/metrics-pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def push_metrics(
name, pushgateway_url, endpoint_name, endpoint_url, scrape_interval, user, password
):
print(f"({endpoint_name}) starting collector")
metrics_session = requests.Session()
session = requests.Session()
if user is not None and password is not None:
session.auth = (user, password)
Expand All @@ -26,7 +27,7 @@ def push_metrics(
f"({endpoint_name}) collecting metrics from: {endpoint_url} [{interval_offset}s]"
)

resp = session.get(endpoint_url)
resp = metrics_session.get(endpoint_url)
if resp.status_code != 200:
print(
f"({endpoint_name}) failed to collect metrics [status_code={resp.status_code}]"
Expand Down

0 comments on commit 1d68129

Please sign in to comment.