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

[meraki] Log getDevicePerformanceScores errors #41622

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -208,6 +208,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- 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*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions x-pack/metricbeat/module/meraki/device_health/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"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"
Expand Down Expand Up @@ -67,7 +68,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 {
Expand All @@ -76,16 +77,19 @@ 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() == 400 && strings.Contains(string(res.Body()), "Feature not supported") {
continue
}

logger.Errorf("GetDeviceAppliancePerformance failed; [%d] %s. %v", res.StatusCode(), res.Body(), err)
continue
gpop63 marked this conversation as resolved.
Show resolved Hide resolved
}

// 204 indicates there is no data for the device, it's likely 'offline' or 'dormant'
if res.StatusCode() != 204 {
device.performanceScore = val
}
}

return nil
}

func getDeviceChannelUtilization(client *meraki.Client, devices map[Serial]*Device, period time.Duration) error {
Expand Down
Loading