From c7b4ef9a895d2d02c04a48980a0c5bcd5d1aa26f Mon Sep 17 00:00:00 2001 From: David Roberts Date: Tue, 3 Oct 2017 12:09:59 +0100 Subject: [PATCH] Add cgroup memory usage/limit to OS stats on Linux (elastic/x-pack-elasticsearch#2614) This change adapts the monitoring tests to account for an addition to the OS stats made in elastic/elasticsearch#26166. Original commit: elastic/x-pack-elasticsearch@9e36764857ac61125ce99555c4152c7c9b088bdf --- .../collector/node/NodeStatsMonitoringDoc.java | 5 ++++- .../exporter/MonitoringTemplateUtils.java | 2 +- plugin/src/main/resources/monitoring-alerts.json | 2 +- plugin/src/main/resources/monitoring-es.json | 13 +++++++++++++ .../collector/node/NodeStatsMonitoringDocTests.java | 8 +++++++- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java index 2bab3e886f0..0e7d7cd7962 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java @@ -119,6 +119,9 @@ public class NodeStatsMonitoringDoc extends FilteredMonitoringDoc { "node_stats.os.cgroup.cpu.stat.number_of_elapsed_periods", "node_stats.os.cgroup.cpu.stat.number_of_times_throttled", "node_stats.os.cgroup.cpu.stat.time_throttled_nanos", + "node_stats.os.cgroup.memory.control_group", + "node_stats.os.cgroup.memory.limit_in_bytes", + "node_stats.os.cgroup.memory.usage_in_bytes", "node_stats.os.cpu.load_average.1m", "node_stats.os.cpu.load_average.5m", "node_stats.os.cpu.load_average.15m", @@ -155,4 +158,4 @@ public class NodeStatsMonitoringDoc extends FilteredMonitoringDoc { "node_stats.thread_pool.watcher.threads", "node_stats.thread_pool.watcher.queue", "node_stats.thread_pool.watcher.rejected"); -} \ No newline at end of file +} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java index bbea6af068f..72a18a4ce7e 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtils.java @@ -26,7 +26,7 @@ public final class MonitoringTemplateUtils { *

* It may be possible for this to diverge between templates and pipelines, but for now they're the same. */ - public static final int LAST_UPDATED_VERSION = Version.V_6_0_0_beta1.id; + public static final int LAST_UPDATED_VERSION = Version.V_7_0_0_alpha1.id; /** * Current version of templates used in their name to differentiate from breaking changes (separate from product version). diff --git a/plugin/src/main/resources/monitoring-alerts.json b/plugin/src/main/resources/monitoring-alerts.json index 4f8f8a657f4..e59bb08e275 100644 --- a/plugin/src/main/resources/monitoring-alerts.json +++ b/plugin/src/main/resources/monitoring-alerts.json @@ -1,6 +1,6 @@ { "index_patterns": ".monitoring-alerts-${monitoring.template.version}", - "version": 6000026, + "version": 7000001, "settings": { "index": { "number_of_shards": 1, diff --git a/plugin/src/main/resources/monitoring-es.json b/plugin/src/main/resources/monitoring-es.json index 8138b01c5d6..2f9eed84150 100644 --- a/plugin/src/main/resources/monitoring-es.json +++ b/plugin/src/main/resources/monitoring-es.json @@ -639,6 +639,19 @@ } } } + }, + "memory": { + "properties": { + "control_group": { + "type": "keyword" + }, + "limit_in_bytes": { + "type": "keyword" + }, + "usage_in_bytes": { + "type": "keyword" + } + } } } }, diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java index 4a1fe7e0dc7..c079429589c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java @@ -188,6 +188,11 @@ public class NodeStatsMonitoringDocTests extends BaseFilteredMonitoringDocTestCa + "\"number_of_times_throttled\":45," + "\"time_throttled_nanos\":46" + "}" + + "}," + + "\"memory\":{" + + "\"control_group\":\"_memory_ctrl_group\"," + + "\"limit_in_bytes\":\"2000000000\"," + + "\"usage_in_bytes\":\"1000000000\"" + "}" + "}" + "}," @@ -327,7 +332,8 @@ public class NodeStatsMonitoringDocTests extends BaseFilteredMonitoringDocTestCa // Os final OsStats.Cpu osCpu = new OsStats.Cpu((short) no, new double[]{++iota, ++iota, ++iota}); final OsStats.Cgroup.CpuStat osCpuStat = new OsStats.Cgroup.CpuStat(++iota, ++iota, ++iota); - final OsStats.Cgroup osCgroup = new OsStats.Cgroup("_cpu_acct_ctrl_group", ++iota, "_cpu_ctrl_group", ++iota, ++iota, osCpuStat); + final OsStats.Cgroup osCgroup = new OsStats.Cgroup("_cpu_acct_ctrl_group", ++iota, "_cpu_ctrl_group", ++iota, ++iota, osCpuStat, + "_memory_ctrl_group", "2000000000", "1000000000"); final OsStats.Mem osMem = new OsStats.Mem(no, no); final OsStats.Swap osSwap = new OsStats.Swap(no, no);