diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index a0eeafda5a2..c78075fb0b8 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -878,6 +878,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Adjust the Apache status fields in the fleet mode. {pull}22821[22821] - Add AWS Fargate overview dashboard. {pull}22941[22941] - Add process.state, process.cpu.pct, process.cpu.start_time and process.memory.pct. {pull}22845[22845] +- Apache: convert status.total_kbytes to status.total_bytes in fleet mode. {pull}23022[23022] *Packetbeat* diff --git a/metricbeat/module/apache/status/data.go b/metricbeat/module/apache/status/data.go index 0c57bc34357..fdfab72e0b9 100644 --- a/metricbeat/module/apache/status/data.go +++ b/metricbeat/module/apache/status/data.go @@ -129,7 +129,7 @@ func eventMapping(scanner *bufio.Scanner, hostname string) (common.MapStr, error for scanner.Scan() { if match := matchNumber.FindStringSubmatch(scanner.Text()); len(match) == 3 { // Total Accesses: 16147 - //Total kBytes: 12988 + // Total kBytes: 12988 // Uptime: 3229728 // CPULoad: .000408393 // CPUUser: 0 diff --git a/metricbeat/module/apache/status/status.go b/metricbeat/module/apache/status/status.go index fa6e033ee77..73be8be1ec5 100644 --- a/metricbeat/module/apache/status/status.go +++ b/metricbeat/module/apache/status/status.go @@ -109,6 +109,13 @@ func adjustFleetEvent(event mb.Event) mb.Event { var adjusted mb.Event adjusted.MetricSetFields = event.MetricSetFields.Clone() + // Convert apache.status.total_kbytes to apache.status.total_bytes + totalKBytes, err := adjusted.MetricSetFields.GetValue("total_kbytes") + if err == nil { + adjusted.MetricSetFields.Put("total_bytes", totalKBytes.(int64)*1024) + adjusted.MetricSetFields.Delete("total_kbytes") + } + // Remove apache.hostname adjusted.MetricSetFields.Delete("hostname") return adjusted diff --git a/metricbeat/module/apache/status/status_integration_test.go b/metricbeat/module/apache/status/status_integration_test.go index b5abc0170f6..b441f63e351 100644 --- a/metricbeat/module/apache/status/status_integration_test.go +++ b/metricbeat/module/apache/status/status_integration_test.go @@ -68,8 +68,15 @@ func TestFetchFleetMode(t *testing.T) { t.Fatal("Too few top-level elements in the event") } - _, err := event.MetricSetFields.GetValue("hostname") - assert.Equal(t, common.ErrKeyNotFound, err, "apache.hostname shouldn't be present in the fleet mode") + _, err := event.MetricSetFields.GetValue("total_kbytes") + assert.Equal(t, common.ErrKeyNotFound, err, "apache.status.total_kbytes shouldn't be present in the fleet mode") + + totalBytes, err := event.MetricSetFields.GetValue("total_bytes") + assert.NoError(t, err, "apache.status.total_bytes should be present in the fleet mode") + assert.GreaterOrEqual(t, totalBytes.(int64), int64(0), "apache.status.total_bytes should be non-negative") + + _, err = event.MetricSetFields.GetValue("hostname") + assert.Equal(t, common.ErrKeyNotFound, err, "apache.status.hostname shouldn't be present in the fleet mode") } func getConfig(host string) map[string]interface{} {