Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-include node_stats metricset when xpack.enabled: true is set #20613

1 change: 1 addition & 0 deletions metricbeat/module/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func NewModule(base mb.BaseModule) (mb.Module, error) {
"index_recovery",
"index_summary",
"ml_job",
"node_stats",
"shard",
}
return elastic.NewModule(&base, xpackEnabledMetricSets, logp.NewLogger(ModuleName))
Expand Down
15 changes: 13 additions & 2 deletions metricbeat/module/elasticsearch/elasticsearch_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestXPackEnabled(t *testing.T) {
"index_recovery": []string{"index_recovery"},
"index_summary": []string{"indices_stats"},
"ml_job": []string{"job_stats"},
"node_stats": []string{"node_stats"},
"node_stats": []string{}, // no longer indexed into .monitoring-es-*
}

config := getXPackConfig(host)
Expand Down Expand Up @@ -177,8 +177,19 @@ func TestXPackEnabled(t *testing.T) {
}

types := metricSetToTypesMap[metricSet.Name()]
require.Len(t, events, len(types))
numTypes := len(types)

// If no types are returned for this metricset, then it's because this metricset
// is no longer indexing events into .monitoring-* indices. But instead it is indexing
// events into the default Metricbeat indices.
if numTypes == 0 {
for _, event := range events {
require.Empty(t, event.Index)
}
return
}

require.Len(t, events, numTypes)
for i, event := range events {
require.Equal(t, types[i], event.RootFields["type"])
require.Regexp(t, `^.monitoring-es-\d-mb`, event.Index)
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/elasticsearch/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func TestXPackEnabledMetricsets(t *testing.T) {
}

metricSets := mbtest.NewReportingMetricSetV2Errors(t, config)
require.Len(t, metricSets, 8)
require.Len(t, metricSets, 9)
for _, ms := range metricSets {
name := ms.Name()
switch name {
case "ccr", "enrich", "cluster_stats", "index", "index_recovery",
"index_summary", "ml_job", "shard":
"index_summary", "ml_job", "node_stats", "shard":
default:
t.Errorf("unexpected metricset name = %v", name)
}
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/module/elasticsearch/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def test_xpack_cluster_stats(self):
"index_recovery",
"index_summary",
"ml_job",
"node_stats",
"shard"
],
"hosts": self.get_hosts(),
Expand All @@ -144,6 +145,9 @@ def test_xpack_cluster_stats(self):

docs = self.read_output_json()
for doc in docs:
if "type" not in doc:
continue

t = doc["type"]
if t != "cluster_stats":
continue
Expand Down