diff --git a/src/main/java/org/datadog/jmxfetch/App.java b/src/main/java/org/datadog/jmxfetch/App.java index 049616087..3b5079d2b 100644 --- a/src/main/java/org/datadog/jmxfetch/App.java +++ b/src/main/java/org/datadog/jmxfetch/App.java @@ -839,6 +839,11 @@ private void sendServiceCheck( private void sendCanConnectServiceCheck(Reporter reporter, String checkName, String serviceCheckPrefix, String status, String message, String[] tags) { String serviceCheckName = String.format("%s.can_connect", serviceCheckPrefix); + + if (status != Status.STATUS_ERROR) { + message = null; + } + reporter.sendServiceCheck( checkName, serviceCheckName, status, message, tags); } diff --git a/src/test/java/org/datadog/jmxfetch/TestServiceChecks.java b/src/test/java/org/datadog/jmxfetch/TestServiceChecks.java index 073248ddb..f416b91c0 100644 --- a/src/test/java/org/datadog/jmxfetch/TestServiceChecks.java +++ b/src/test/java/org/datadog/jmxfetch/TestServiceChecks.java @@ -74,8 +74,9 @@ public void testServiceCheckWarning() throws Exception { assertNotNull(sc.get("name")); assertNotNull(sc.get("status")); - // Message should not be null anymore and reports a high number of metrics warning - assertNotNull(sc.get("message")); + // Despite there being a high number of metrics warning, message should be null. + // Non-ERROR statuses are set to OK, and OK statuses should have null messages. + assertNull(sc.get("message")); assertNotNull(sc.get("tags")); String scName = (String) (sc.get("name"));