From dc9556514969d076ed1c2dc369b7fc992bf9943c Mon Sep 17 00:00:00 2001 From: Gabriel Pop <94497545+gpop63@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:29:16 +0200 Subject: [PATCH] [meraki] Log `getDevicePerformanceScores` errors (#41622) * log getDevicePerformanceScores errors * add changelog entry * fix PR id * Update x-pack/metricbeat/module/meraki/device_health/devices.go Co-authored-by: Tom Myers <106530686+tommyers-elastic@users.noreply.github.com> * Update x-pack/metricbeat/module/meraki/device_health/devices.go Co-authored-by: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com> * fix imports --------- Co-authored-by: Tom Myers <106530686+tommyers-elastic@users.noreply.github.com> Co-authored-by: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com> (cherry picked from commit f35602f3f1754e2e08626a0eb26f31a35a535c13) --- CHANGELOG.next.asciidoc | 3 +++ .../module/meraki/device_health/device_health.go | 5 +---- .../module/meraki/device_health/devices.go | 12 ++++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 4ed2d6a4f888..d3beaf0638f7 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -211,6 +211,9 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Use namespace for GetListMetrics when exists in AWS {pull}41022[41022] - Fix http server helper SSL config. {pull}39405[39405] - Fix Kubernetes metadata sometimes not being present after startup {pull}41216[41216] +- Do not report non-existant 0 values for RSS metrics in docker/memory {pull}41449[41449] +- Log Cisco Meraki `getDevicePerformanceScores` errors without stopping metrics collection. {pull}41622[41622] + *Osquerybeat* diff --git a/x-pack/metricbeat/module/meraki/device_health/device_health.go b/x-pack/metricbeat/module/meraki/device_health/device_health.go index 25d41bf43f5e..bbe301b3b430 100644 --- a/x-pack/metricbeat/module/meraki/device_health/device_health.go +++ b/x-pack/metricbeat/module/meraki/device_health/device_health.go @@ -98,10 +98,7 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) error { return fmt.Errorf("getDeviceStatuses failed; %w", err) } - err = getDevicePerformanceScores(m.client, devices) - if err != nil { - return fmt.Errorf("getDevicePerformanceScores failed; %w", err) - } + getDevicePerformanceScores(m.logger, m.client, devices) err = getDeviceChannelUtilization(m.client, devices, collectionPeriod) if err != nil { diff --git a/x-pack/metricbeat/module/meraki/device_health/devices.go b/x-pack/metricbeat/module/meraki/device_health/devices.go index 2f2591d6783e..c76b76def78f 100644 --- a/x-pack/metricbeat/module/meraki/device_health/devices.go +++ b/x-pack/metricbeat/module/meraki/device_health/devices.go @@ -6,10 +6,12 @@ package device_health import ( "fmt" + "net/http" "strings" "time" "github.com/elastic/beats/v7/metricbeat/mb" + "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" meraki "github.com/meraki/dashboard-api-go/v3/sdk" @@ -67,7 +69,7 @@ func getDeviceStatuses(client *meraki.Client, organizationID string, devices map return nil } -func getDevicePerformanceScores(client *meraki.Client, devices map[Serial]*Device) error { +func getDevicePerformanceScores(logger *logp.Logger, client *meraki.Client, devices map[Serial]*Device) { for _, device := range devices { // attempting to get a performance score for a non-MX device returns a 400 if strings.Index(device.details.Model, "MX") != 0 { @@ -76,7 +78,11 @@ func getDevicePerformanceScores(client *meraki.Client, devices map[Serial]*Devic val, res, err := client.Appliance.GetDeviceAppliancePerformance(device.details.Serial) if err != nil { - return fmt.Errorf("GetDeviceAppliancePerformance failed; [%d] %s. %w", res.StatusCode(), res.Body(), err) + if !(res.StatusCode() != http.StatusBadRequest && strings.Contains(string(res.Body()), "Feature not supported")) { + logger.Errorf("GetDeviceAppliancePerformance failed; [%d] %s. %v", res.StatusCode(), res.Body(), err) + } + + continue } // 204 indicates there is no data for the device, it's likely 'offline' or 'dormant' @@ -84,8 +90,6 @@ func getDevicePerformanceScores(client *meraki.Client, devices map[Serial]*Devic device.performanceScore = val } } - - return nil } func getDeviceChannelUtilization(client *meraki.Client, devices map[Serial]*Device, period time.Duration) error {