Skip to content

Commit

Permalink
Add support for additional Netdata instances and improve error handli…
Browse files Browse the repository at this point in the history
…ng in ingestion functions
  • Loading branch information
andrewm4894 committed Dec 30, 2024
1 parent d10ea5c commit 980fe2c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
15 changes: 14 additions & 1 deletion metrics/examples/netdata/netdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ def ingest() -> pd.DataFrame:
("london.my-netdata.io", "system.cpu", "-600", "0"),
("london.my-netdata.io", "system.io", "-600", "0"),
("london.my-netdata.io", "system.ram", "-600", "0"),
("bangalore.my-netdata.io", "system.net", "-600", "0"),
("bangalore.my-netdata.io", "system.cpu", "-600", "0"),
("bangalore.my-netdata.io", "system.io", "-600", "0"),
("bangalore.my-netdata.io", "system.ram", "-600", "0"),
("frankfurt.my-netdata.io", "system.net", "-600", "0"),
("frankfurt.my-netdata.io", "system.cpu", "-600", "0"),
("frankfurt.my-netdata.io", "system.io", "-600", "0"),
("frankfurt.my-netdata.io", "system.ram", "-600", "0"),
]

urls = [
Expand All @@ -26,7 +34,12 @@ def ingest() -> pd.DataFrame:
]
df = pd.DataFrame()
for url, (host, chart, _, _) in zip(urls, inputs):
res = requests.get(url)
try:
res = requests.get(url, timeout=10)
res.raise_for_status()
except requests.exceptions.RequestException as e:
logger.error(f"Failed to fetch data from {url}: {e}")
continue
data = res.text.split("\r\n")
cols = data[0].split(",")
values = data[1].split(",")
Expand Down
2 changes: 0 additions & 2 deletions metrics/examples/netdata/netdata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ disable_llmalert: False
alert_methods: "email,slack"
ingest_fn: >
{% include "./examples/netdata/netdata.py" %}
change_exclude_metrics:
- london__system_io_reads
7 changes: 6 additions & 1 deletion metrics/examples/netdata_httpcheck/netdata_httpcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ def ingest() -> pd.DataFrame:
]
df = pd.DataFrame()
for url, (host, chart, _, _) in zip(urls, inputs):
res = requests.get(url)
try:
res = requests.get(url, timeout=10)
res.raise_for_status()
except requests.exceptions.RequestException as e:
logger.error(f"Failed to fetch data from {url}: {e}")
continue
data = res.text.split("\r\n")
cols = data[0].split(",")
cols[0] = "metric_timestamp"
Expand Down

0 comments on commit 980fe2c

Please sign in to comment.