From dfcbbfcb5fb1d8fd696941986f332d7489a7cbf5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:52:45 +0200 Subject: [PATCH] [metricbeat] [meraki] Ignore 400 error for unsupported per-device licensing (#42397) (#42466) * dont error in getDeviceLicenses * add changelog entry * fix pr id * keep error and check for bad request * check response body --------- Co-authored-by: Ishleen Kaur <102962586+ishleenk17@users.noreply.github.com> (cherry picked from commit b5f726b81c7fdb3d57615d5dd8be31036182302c) Co-authored-by: Gabriel Pop <94497545+gpop63@users.noreply.github.com> --- CHANGELOG.next.asciidoc | 1 + x-pack/metricbeat/module/meraki/device_health/devices.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index e82a559f38ab..49e5ba3caa53 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -209,6 +209,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Fixed `creation_date` scientific notation output in the `elasticsearch.index` metricset. {pull}42053[42053] - Fix bug where metricbeat unintentionally triggers Windows ASR. {pull}42177[42177] - Remove `hostname` field from zookeeper's `mntr` data stream. {pull}41887[41887] +- Continue collecting metrics even if the Cisco Meraki `getDeviceLicenses` operation fails. {pull}42397[42397] *Osquerybeat* diff --git a/x-pack/metricbeat/module/meraki/device_health/devices.go b/x-pack/metricbeat/module/meraki/device_health/devices.go index c76b76def78f..894393647a2e 100644 --- a/x-pack/metricbeat/module/meraki/device_health/devices.go +++ b/x-pack/metricbeat/module/meraki/device_health/devices.go @@ -150,6 +150,10 @@ func getDeviceChannelUtilization(client *meraki.Client, devices map[Serial]*Devi func getDeviceLicenses(client *meraki.Client, organizationID string, devices map[Serial]*Device) error { val, res, err := client.Organizations.GetOrganizationLicenses(organizationID, &meraki.GetOrganizationLicensesQueryParams{}) if err != nil { + // Ignore 400 error for per-device licensing not supported + if res.StatusCode() == 400 && strings.Contains(string(res.Body()), "does not support per-device licensing") { + return nil + } return fmt.Errorf("GetOrganizationLicenses failed; [%d] %s. %w", res.StatusCode(), res.Body(), err) }