From eb621b5ce825a622aae008506d1ee3507be44c94 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 7 Jul 2020 08:42:57 -0700 Subject: [PATCH] Hybrid approach --- metricbeat/module/elasticsearch/elasticsearch.go | 10 +++++++--- metricbeat/module/elasticsearch/index/data_xpack.go | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/metricbeat/module/elasticsearch/elasticsearch.go b/metricbeat/module/elasticsearch/elasticsearch.go index 10bcc13ca611..48050b224cc0 100644 --- a/metricbeat/module/elasticsearch/elasticsearch.go +++ b/metricbeat/module/elasticsearch/elasticsearch.go @@ -379,7 +379,7 @@ func (b *boolStr) UnmarshalJSON(raw []byte) error { } type IndexSettings struct { - Hidden boolStr + Hidden bool } // GetIndicesSettings returns a map of index names to their settings. @@ -394,7 +394,9 @@ func GetIndicesSettings(http *helper.HTTP, resetURI string) (map[string]IndexSet var resp map[string]struct { Settings struct { - Index IndexSettings `json:"index"` + Index struct { + Hidden boolStr `json:"hidden"` + } `json:"index"` } `json:"settings"` } @@ -405,7 +407,9 @@ func GetIndicesSettings(http *helper.HTTP, resetURI string) (map[string]IndexSet ret := make(map[string]IndexSettings, len(resp)) for index, settings := range resp { - ret[index] = settings.Settings.Index + ret[index] = IndexSettings{ + Hidden: bool(settings.Settings.Index.Hidden), + } } return ret, nil diff --git a/metricbeat/module/elasticsearch/index/data_xpack.go b/metricbeat/module/elasticsearch/index/data_xpack.go index 46e41764d9a5..b137e06364b3 100644 --- a/metricbeat/module/elasticsearch/index/data_xpack.go +++ b/metricbeat/module/elasticsearch/index/data_xpack.go @@ -154,7 +154,7 @@ func eventsMappingXPack(r mb.ReporterV2, m *MetricSet, info elasticsearch.Info, settings, exists := indicesSettings[name] if exists { - idx.Hidden = bool(settings.Hidden) + idx.Hidden = settings.Hidden } err = addClusterStateFields(&idx, clusterState)