Skip to content

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

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

Merged
merged 7 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -243,6 +243,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}42397[42397]

*Osquerybeat*

Expand Down
4 changes: 4 additions & 0 deletions x-pack/metricbeat/module/meraki/device_health/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check for any 4xx error and not just 400?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should skip all 4xx error codes, 404 for example could mean the organization was not found meaning the org ID provided in the config is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. but it also can be something different. I mean I'm pretty sure that even 400 can be returned in multiple cases (something else can be invalid, might not be related to licensing not being supported, right?)

Copy link
Member

@mauri870 mauri870 Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring any 400 error seems too broad. Isn't it better to just read the response body and assert that status is 400 AND body contains "does not support per-device licensing"? I understand that this could be the only possible 400 response for this endpoint and we can skip the check, but that does not guarantee that other 400 errors can't be returned by this endpoint in the future and break this logic. I would rather be future proof.

return nil
}
return fmt.Errorf("GetOrganizationLicenses failed; [%d] %s. %w", res.StatusCode(), res.Body(), err)
}

Expand Down
Loading