From 84d4b0dc7358954171ebd835cfd585ed3f46cc6c Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Oct 2018 11:49:38 -0700 Subject: [PATCH] Relax check to account for metricbeat-indexed doc format (#23730) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With Metricbeat shipping Elasticsearch monitoring data (instead of internal collection by Elasticsearch), there are some subtle changes to the format of monitoring docs that are indexed into `.monitoring-es-6-*`. One such change is that metricbeat won't index fields with `null` values; instead it simply doesn't index such fields at all. As a result, in the context of Elasticsearch monitoring docs, when it comes to docs with `type` = `shards` representing unassigned shards, the `shard.node` field was being indexed as `null` by internal Elasticearch collection, whereas the field was absent when the doc was indexed by Metricbeat. Since both cases represent the same case — the shard being unassigned — this PR relaxes the check in the UI code to look for either case. ### Sample `shards` document indexed by internal ES collection ```js { "_index":".monitoring-es-6-2018.10.02", "_type":"doc", "_id":"WUf_htOeSXOJQmiesyF5Bw:_na:metricbeat-7.0.0-alpha1-2018.10.01:0:r", "_source":{ "cluster_uuid":"zXO1GjA6SJGsrPnCPkOoyA", "timestamp":"2018-10-02T03:54:43.364Z", "interval_ms":10000, "type":"shards", "source_node":null, "state_uuid":"WUf_htOeSXOJQmiesyF5Bw", "shard":{ "state":"UNASSIGNED", "primary":false, "node":null, "relocating_node":null, "shard":0, "index":"metricbeat-7.0.0-alpha1-2018.10.01" } } } ``` ### Sample `shards` document indexed by Metricbeat collection ```js { "_index":".monitoring-es-6-mb-2018.10.02", "_type":"doc", "_id":"FhDRTPjkQJqsgawYbxjQzw:_na:metricbeat-7.0.0-alpha1-2018.10.01:0:r", "_source":{ "@timestamp":"2018-10-02T04:00:03.361Z", "interval_ms":10000, "shard":{ "state":"UNASSIGNED", "primary":false, "index":"metricbeat-7.0.0-alpha1-2018.10.01", "shard":0 }, "state_uuid":"FhDRTPjkQJqsgawYbxjQzw", "beat":{ "hostname":"Shaunaks-MBP-2", "version":"7.0.0-alpha1", "name":"Shaunaks-MBP-2" }, "timestamp":"2018-10-02T04:00:03.375Z", "type":"shards", "metricset":{ "name":"shard", "module":"elasticsearch", "host":"localhost:9200", "rtt":14254, "namespace":"elasticsearch.shard" }, "host":{ "name":"Shaunaks-MBP-2" }, "cluster_uuid":"zXO1GjA6SJGsrPnCPkOoyA" } } ``` --- .../shard_allocation/transformers/indices_by_nodes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/monitoring/public/directives/elasticsearch/shard_allocation/transformers/indices_by_nodes.js b/x-pack/plugins/monitoring/public/directives/elasticsearch/shard_allocation/transformers/indices_by_nodes.js index 79f3a995097e..c9ec0acaae91 100644 --- a/x-pack/plugins/monitoring/public/directives/elasticsearch/shard_allocation/transformers/indices_by_nodes.js +++ b/x-pack/plugins/monitoring/public/directives/elasticsearch/shard_allocation/transformers/indices_by_nodes.js @@ -33,7 +33,7 @@ export function indicesByNodes() { // If the node is null then it's an unassigned shard and we need to // add it to the unassigned array. - if (shard.node === null) { + if (!shard.node || (shard.node === null)) { obj[index].unassigned.push(shard); // if the shard is a primary we need to set the unassignedPrimaries flag if (shard.primary) {