diff --git a/src/main/java/org/datadog/jmxfetch/Status.java b/src/main/java/org/datadog/jmxfetch/Status.java index 178393217..97e8aa2d0 100644 --- a/src/main/java/org/datadog/jmxfetch/Status.java +++ b/src/main/java/org/datadog/jmxfetch/Status.java @@ -126,7 +126,7 @@ private String generateJson() throws IOException { Map status = new HashMap(); status.put("timestamp", System.currentTimeMillis()); status.put("checks", this.instanceStats); - return JSON.std.asString(status); + return JSON.std.with(JSON.Feature.WRITE_NULL_PROPERTIES).asString(status); } /** Flushes current status. */ diff --git a/src/main/java/org/datadog/jmxfetch/reporter/JsonReporter.java b/src/main/java/org/datadog/jmxfetch/reporter/JsonReporter.java index 1bad178e4..123016b6f 100644 --- a/src/main/java/org/datadog/jmxfetch/reporter/JsonReporter.java +++ b/src/main/java/org/datadog/jmxfetch/reporter/JsonReporter.java @@ -47,7 +47,7 @@ public void doSendServiceCheck( sc.put("status", this.statusToServiceCheckStatusValue(status)); sc.put("message", message); sc.put("tags", tags); - + Map aggregator = new HashMap(); aggregator.put("metrics", metrics); List serviceChecks = new ArrayList(); @@ -60,7 +60,12 @@ public void doSendServiceCheck( System.out.println("=== JSON ==="); try { - System.out.println(JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT).asString(series)); + System.out.println( + JSON.std.with( + JSON.Feature.PRETTY_PRINT_OUTPUT, + JSON.Feature.WRITE_NULL_PROPERTIES + ).asString(series) + ); } catch (IOException e) { log.error("Couln't produce JSON output"); }