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

[metricbeat] [meraki] Ignore 400 error for unsupported per-device licensing #42397

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- [K8s Integration] Enhance HTTP authentication in case of token updates for Apiserver, Controllermanager and Scheduler metricsets {issue}41910[41910] {pull}42016[42016]
- 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]
- Continue collecting metrics even if the Cisco Meraki `getDeviceLicenses` operation fails. {pull}0[0]

*Osquerybeat*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) error {
return fmt.Errorf("getDeviceChannelUtilization failed; %w", err)
}

err = getDeviceLicenses(m.client, org, devices)
if err != nil {
return fmt.Errorf("getDeviceLicenses failed; %w", err)
}
getDeviceLicenses(m.client, org, devices)

err = getDeviceUplinks(m.client, org, devices, collectionPeriod)
if err != nil {
Expand Down
21 changes: 9 additions & 12 deletions x-pack/metricbeat/module/meraki/device_health/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,17 @@ func getDeviceChannelUtilization(client *meraki.Client, devices map[Serial]*Devi
return nil
}

func getDeviceLicenses(client *meraki.Client, organizationID string, devices map[Serial]*Device) error {
val, res, err := client.Organizations.GetOrganizationLicenses(organizationID, &meraki.GetOrganizationLicensesQueryParams{})
if err != nil {
return fmt.Errorf("GetOrganizationLicenses failed; [%d] %s. %w", res.StatusCode(), res.Body(), err)
}

for i := range *val {
license := (*val)[i]
if device, ok := devices[Serial(license.DeviceSerial)]; ok {
device.license = &license
func getDeviceLicenses(client *meraki.Client, organizationID string, devices map[Serial]*Device) {
val, _, _ := client.Organizations.GetOrganizationLicenses(organizationID, &meraki.GetOrganizationLicensesQueryParams{})
gpop63 marked this conversation as resolved.
Show resolved Hide resolved

if val != nil {
for i := range *val {
license := (*val)[i]
if device, ok := devices[Serial(license.DeviceSerial)]; ok {
device.license = &license
}
}
}

return nil
}

func deviceDetailsToMapstr(details *meraki.ResponseItemOrganizationsGetOrganizationDevices) mapstr.M {
Expand Down
Loading