diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index a6b3a6b7f5b..628597e6489 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -118,6 +118,24 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - [Metricbeat][Kubernetes] Change cluster_ip field from ip to keyword. {pull}20571[20571] - The `o365input` and `o365` module now recover from an authentication problem or other fatal errors, instead of terminating. {pull}21258[21258] - Beats dashboards use custom index when `setup.dashboards.index` is set. {issue}21232[21232] {pull}27901[27901] +- Rename cloud.provider `az` value to `azure` inside the add_cloud_metadata processor. {pull}20689[20689] +- Add missing country_name geo field in `add_host_metadata` and `add_observer_metadata` processors. {issue}20796[20796] {pull}20811[20811] +- [Autodiscover] Handle input-not-finished errors in config reload. {pull}20915[20915] +- Explicitly detect missing variables in autodiscover configuration, log them at the debug level. {issue}20568[20568] {pull}20898[20898] +- Fix `libbeat.output.write.bytes` and `libbeat.output.read.bytes` metrics of the Elasticsearch output. {issue}20752[20752] {pull}21197[21197] +- Orderly close processors when processing pipelines are not needed anymore to release their resources. {pull}16349[16349] +- Fix memory leak and events duplication in docker autodiscover and add_docker_metadata. {pull}21851[21851] +- Fixed documentation for commands in beats dev guide {pull}22194[22194] +- Fix parsing of expired licences. {issue}21112[21112] {pull}22180[22180] +- Fix duplicated pod events in kubernetes autodiscover for pods with init or ephemeral containers. {pull}22438[22438] +- Fix FileVersion contained in Windows exe files. {pull}22581[22581] +- Fix index template loading when the new index format is selected. {issue}22482[22482] {pull}22682[22682] +- Periodic metrics in logs will now report `libbeat.output.events.active` and `beat.memstats.rss` + as gauges (rather than counters). {pull}22877[22877] +- Improve `perfmon` metricset performance. {pull}26886[26886] +- Preserve annotations in a kubernetes namespace metadata {pull}27045[27045] +- Allow conditional processing in `decode_xml` and `decode_xml_wineventlog`. {pull}27159[27159] +- Fix build constraint that caused issues with doc builds. {pull}27381[27381] *Auditbeat* diff --git a/metricbeat/internal/metrics/memory/memory_helpers.go b/metricbeat/internal/metrics/memory/memory_helpers.go new file mode 100644 index 00000000000..0761e910146 --- /dev/null +++ b/metricbeat/internal/metrics/memory/memory_helpers.go @@ -0,0 +1,79 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package memory + +import ( + "bufio" + "bytes" + "io" + "io/ioutil" + "path/filepath" + "strconv" + "strings" + + "github.com/pkg/errors" +) + +// ParseMeminfo parses the contents of /proc/meminfo into a hashmap +func ParseMeminfo(rootfs string) (map[string]uint64, error) { + table := map[string]uint64{} + + meminfoPath := filepath.Join(rootfs, "/proc/meminfo") + err := readFile(meminfoPath, func(line string) bool { + fields := strings.Split(line, ":") + + if len(fields) != 2 { + return true // skip on errors + } + + valueUnit := strings.Fields(fields[1]) + value, err := strconv.ParseUint(valueUnit[0], 10, 64) + if err != nil { + return true // skip on errors + } + + if len(valueUnit) > 1 && valueUnit[1] == "kB" { + value *= 1024 + } + table[fields[0]] = value + + return true + }) + return table, err +} + +func readFile(file string, handler func(string) bool) error { + contents, err := ioutil.ReadFile(file) + if err != nil { + return errors.Wrapf(err, "error reading file %s", file) + } + + reader := bufio.NewReader(bytes.NewBuffer(contents)) + + for { + line, _, err := reader.ReadLine() + if err == io.EOF { + break + } + if !handler(string(line)) { + break + } + } + + return nil +} diff --git a/metricbeat/internal/metrics/memory/memory_linux.go b/metricbeat/internal/metrics/memory/memory_linux.go index a97a6c0a08c..bc9b8b33972 100644 --- a/metricbeat/internal/metrics/memory/memory_linux.go +++ b/metricbeat/internal/metrics/memory/memory_linux.go @@ -18,14 +18,6 @@ package memory import ( - "bufio" - "bytes" - "io" - "io/ioutil" - "path/filepath" - "strconv" - "strings" - "github.com/pkg/errors" "github.com/elastic/beats/v7/libbeat/opt" @@ -92,52 +84,3 @@ func get(rootfs string) (Memory, error) { return memData, nil } - -// ParseMeminfo parses the contents of /proc/meminfo into a hashmap -func ParseMeminfo(rootfs string) (map[string]uint64, error) { - table := map[string]uint64{} - - meminfoPath := filepath.Join(rootfs, "/proc/meminfo") - err := readFile(meminfoPath, func(line string) bool { - fields := strings.Split(line, ":") - - if len(fields) != 2 { - return true // skip on errors - } - - valueUnit := strings.Fields(fields[1]) - value, err := strconv.ParseUint(valueUnit[0], 10, 64) - if err != nil { - return true // skip on errors - } - - if len(valueUnit) > 1 && valueUnit[1] == "kB" { - value *= 1024 - } - table[fields[0]] = value - - return true - }) - return table, err -} - -func readFile(file string, handler func(string) bool) error { - contents, err := ioutil.ReadFile(file) - if err != nil { - return errors.Wrapf(err, "error reading file %s", file) - } - - reader := bufio.NewReader(bytes.NewBuffer(contents)) - - for { - line, _, err := reader.ReadLine() - if err == io.EOF { - break - } - if !handler(string(line)) { - break - } - } - - return nil -} diff --git a/metricbeat/module/linux/memory/data.go b/metricbeat/module/linux/memory/data.go index eb4706e02f0..ddf2cfc0797 100644 --- a/metricbeat/module/linux/memory/data.go +++ b/metricbeat/module/linux/memory/data.go @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -// +build linux - package memory import ( @@ -139,7 +137,7 @@ func GetVMStat() (*sysinfotypes.VMStatInfo, error) { } vmstatHandle, ok := h.(sysinfotypes.VMStat) if !ok { - return nil, errors.Wrap(err, "VMStat not available for platform") + return nil, errors.New("VMStat not available for platform") } info, err := vmstatHandle.VMStat() if err != nil { diff --git a/metricbeat/module/linux/memory/memory.go b/metricbeat/module/linux/memory/memory.go index 13f080196ad..35cd407b9b3 100644 --- a/metricbeat/module/linux/memory/memory.go +++ b/metricbeat/module/linux/memory/memory.go @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -// +build linux - package memory import ( diff --git a/metricbeat/module/linux/memory/memory_test.go b/metricbeat/module/linux/memory/memory_linux_test.go similarity index 98% rename from metricbeat/module/linux/memory/memory_test.go rename to metricbeat/module/linux/memory/memory_linux_test.go index 52b0bdcc7e1..bddecc8f8a7 100644 --- a/metricbeat/module/linux/memory/memory_test.go +++ b/metricbeat/module/linux/memory/memory_linux_test.go @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -// +build linux - package memory import (