From b9689a53171f5e5a5dbf8e8e025c4b85054cbb4b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 11 Feb 2019 18:35:58 -0800 Subject: [PATCH] Fix missing nodes from Node Listing page when using Metricbeat Elasticsearch module with xpack.enabled: true (#10639) (#10672) * Add source_node object to node_stats documents * Adding CHANGELOG entry (cherry picked from commit 6ddaae69afd4fc46c0bbf8c82cd0a676ed7d9fc7) --- CHANGELOG.next.asciidoc | 1 + .../module/elasticsearch/node_stats/data_xpack.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index fa7d16d66d9..9bea82230a8 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -124,6 +124,7 @@ https://github.com/elastic/beats/compare/v6.6.0...6.x[Check the HEAD diff] - Fixed data type for isr field in `kafka/partition` metricset {pull}10307[10307] - Fixed data types for various hosts fields in `mongodb/replstatus` metricset {pull}10307[10307] - Added function to close sql database connection. {pull}10355[10355] +- Fix issue with `elasticsearch/node_stats` metricset (x-pack) not indexing `source_node` field. {pull}10639[10639] *Packetbeat* diff --git a/metricbeat/module/elasticsearch/node_stats/data_xpack.go b/metricbeat/module/elasticsearch/node_stats/data_xpack.go index e59caa97852..69f9bf9ed87 100644 --- a/metricbeat/module/elasticsearch/node_stats/data_xpack.go +++ b/metricbeat/module/elasticsearch/node_stats/data_xpack.go @@ -35,6 +35,8 @@ import ( var ( schemaXpack = s.Schema{ + "name": c.Str("name"), + "transport_address": c.Str("transport_address"), "indices": c.Dict("indices", s.Schema{ "docs": c.Dict("docs", s.Schema{ "count": c.Int("count"), @@ -197,12 +199,22 @@ func eventsMappingXPack(r mb.ReporterV2, m *MetricSet, info elasticsearch.Info, nodeData["node_master"] = isMaster nodeData["node_id"] = nodeID + // Build source_node object + sourceNode := common.MapStr{ + "uuid": nodeID, + "name": nodeData["name"], + "transport_address": nodeData["transport_address"], + } + nodeData.Delete("name") + nodeData.Delete("transport_address") + event.RootFields = common.MapStr{ "timestamp": time.Now(), "cluster_uuid": info.ClusterID, "interval_ms": m.Module().Config().Period.Nanoseconds() / 1000 / 1000, "type": "node_stats", "node_stats": nodeData, + "source_node": sourceNode, } event.Index = elastic.MakeXPackMonitoringIndexName(elastic.Elasticsearch)