diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java index fabca79c5e1..ce8cc8def72 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java @@ -41,6 +41,8 @@ import java.io.IOException; */ public class NodeStats extends NodeOperationResponse { + private long timestamp; + @Nullable private String hostname; @@ -74,10 +76,11 @@ public class NodeStats extends NodeOperationResponse { NodeStats() { } - public NodeStats(DiscoveryNode node, @Nullable String hostname, @Nullable NodeIndicesStats indices, + public NodeStats(DiscoveryNode node, long timestamp, @Nullable String hostname, @Nullable NodeIndicesStats indices, @Nullable OsStats os, @Nullable ProcessStats process, @Nullable JvmStats jvm, @Nullable ThreadPoolStats threadPool, @Nullable NetworkStats network, @Nullable FsStats fs, @Nullable TransportStats transport, @Nullable HttpStats http) { super(node); + this.timestamp = timestamp; this.hostname = hostname; this.indices = indices; this.os = os; @@ -90,6 +93,14 @@ public class NodeStats extends NodeOperationResponse { this.http = http; } + public long timestamp() { + return this.timestamp; + } + + public long getTimestamp() { + return this.timestamp; + } + @Nullable public String hostname() { return this.hostname; @@ -241,6 +252,7 @@ public class NodeStats extends NodeOperationResponse { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); + timestamp = in.readVLong(); if (in.readBoolean()) { hostname = in.readUTF(); } @@ -276,6 +288,7 @@ public class NodeStats extends NodeOperationResponse { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); + out.writeVLong(timestamp); if (hostname == null) { out.writeBoolean(false); } else { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java index 6ed8d1ef5b0..3725d072527 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java @@ -67,6 +67,7 @@ public class NodesStatsResponse extends NodesOperationResponse implem for (NodeStats nodeStats : this) { builder.startObject(nodeStats.node().id(), XContentBuilder.FieldCaseConversion.NONE); + builder.field("timestamp", nodeStats.timestamp()); builder.field("name", nodeStats.node().name(), XContentBuilder.FieldCaseConversion.NONE); builder.field("transport_address", nodeStats.node().address().toString()); diff --git a/src/main/java/org/elasticsearch/node/service/NodeService.java b/src/main/java/org/elasticsearch/node/service/NodeService.java index c4b06980fcc..05660f7cf30 100644 --- a/src/main/java/org/elasticsearch/node/service/NodeService.java +++ b/src/main/java/org/elasticsearch/node/service/NodeService.java @@ -133,7 +133,7 @@ public class NodeService extends AbstractComponent { public NodeStats stats() { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) - return new NodeStats(clusterService.state().nodes().localNode(), hostname, + return new NodeStats(clusterService.state().nodes().localNode(), System.currentTimeMillis(), hostname, indicesService.stats(true), monitorService.osService().stats(), monitorService.processService().stats(), @@ -149,7 +149,7 @@ public class NodeService extends AbstractComponent { public NodeStats stats(boolean indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean network, boolean fs, boolean transport, boolean http) { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) - return new NodeStats(clusterService.state().nodes().localNode(), hostname, + return new NodeStats(clusterService.state().nodes().localNode(), System.currentTimeMillis(), hostname, indices ? indicesService.stats(true) : null, os ? monitorService.osService().stats() : null, process ? monitorService.processService().stats() : null,