Skip to content

Commit aa26b79

Browse files
changhyunijune
and
june
authored
[tcp_checks] If dns-resolve failed don't report metrics. (#17912)
* update tcp checks about dns_resolve * add changed log --------- Co-authored-by: june <mac@macui-MacBookAir.local>
1 parent 0c4c79a commit aa26b79

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tcp_check/changelog.d/17912.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[tcp_checks] If dns-resolve failed don't report metrics.

tcp_check/datadog_checks/tcp_check/tcp_check.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ def check(self, _):
116116
start = get_precise_time() # Avoid initialisation warning
117117

118118
if self.should_resolve_ips():
119-
self.resolve_ips()
120-
self.ip_cache_last_ts = start
119+
try:
120+
self.resolve_ips()
121+
self.ip_cache_last_ts = start
122+
except CheckException as e:
123+
self.log.error("DNS resolution failed: %s", str(e))
124+
self.report_as_service_check(AgentCheck.CRITICAL, "DNS resolution failed", str(e))
125+
return # The dns-resolve failed
121126

122127
self.log.debug("Connecting to %s on port %d", self.host, self.port)
123128

0 commit comments

Comments
 (0)