From d84018ab7a187cdf476acfdbf42f5e4a9d1f0ce8 Mon Sep 17 00:00:00 2001 From: ruflin Date: Wed, 11 Jul 2018 09:03:18 +0200 Subject: [PATCH 1/2] Fix breaking change in monitoring data The prefix for the stats metrics was metrics but renamed to `stats` by accident as the name is now auto generated. This reverts this change. Closes https://github.com/elastic/beats/issues/7562 --- .../monitoring/report/elasticsearch/elasticsearch.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libbeat/monitoring/report/elasticsearch/elasticsearch.go b/libbeat/monitoring/report/elasticsearch/elasticsearch.go index a29950ae674..34d2f35077d 100644 --- a/libbeat/monitoring/report/elasticsearch/elasticsearch.go +++ b/libbeat/monitoring/report/elasticsearch/elasticsearch.go @@ -224,9 +224,15 @@ func (r *reporter) snapshotLoop(namespace string, period time.Duration) { continue } + // Prefix for the inside the event. For backward compatibility stats is renamed to metrics. + prefix := namespace + if namespace == "stats" { + prefix = "metrics" + } + fields := common.MapStr{ - "beat": r.beatMeta, - namespace: snapshot, + "beat": r.beatMeta, + prefix: snapshot, } if len(r.tags) > 0 { fields["tags"] = r.tags From 6d0d5b09ffee3bc829a8d1835afd2ce22794f8c9 Mon Sep 17 00:00:00 2001 From: ruflin Date: Fri, 13 Jul 2018 09:21:17 +0200 Subject: [PATCH 2/2] apply PR review --- .../report/elasticsearch/elasticsearch.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libbeat/monitoring/report/elasticsearch/elasticsearch.go b/libbeat/monitoring/report/elasticsearch/elasticsearch.go index 34d2f35077d..7c9357abdd7 100644 --- a/libbeat/monitoring/report/elasticsearch/elasticsearch.go +++ b/libbeat/monitoring/report/elasticsearch/elasticsearch.go @@ -198,11 +198,12 @@ func (r *reporter) initLoop(c config) { logp.Info("Successfully connected to X-Pack Monitoring endpoint.") // Start collector and send loop if monitoring endpoint has been found. - go r.snapshotLoop("state", c.StatePeriod) - go r.snapshotLoop("stats", c.MetricsPeriod) + go r.snapshotLoop("state", "state", c.StatePeriod) + // For backward compatibility stats is named to metrics. + go r.snapshotLoop("stats", "metrics", c.MetricsPeriod) } -func (r *reporter) snapshotLoop(namespace string, period time.Duration) { +func (r *reporter) snapshotLoop(namespace, prefix string, period time.Duration) { ticker := time.NewTicker(period) defer ticker.Stop() @@ -224,12 +225,6 @@ func (r *reporter) snapshotLoop(namespace string, period time.Duration) { continue } - // Prefix for the inside the event. For backward compatibility stats is renamed to metrics. - prefix := namespace - if namespace == "stats" { - prefix = "metrics" - } - fields := common.MapStr{ "beat": r.beatMeta, prefix: snapshot,