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

x-pack/metricbeat/module/meraki: Add new module #40669

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/icholy/digest v0.1.22
github.com/meraki/dashboard-api-go/v3 v3.0.9
github.com/otiai10/copy v1.12.0
github.com/pierrec/lz4/v4 v4.1.18
github.com/pkg/xattr v0.4.9
Expand Down Expand Up @@ -290,6 +291,7 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-resty/resty/v2 v2.11.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gobuffalo/here v0.6.7 // indirect
github.com/goccy/go-json v0.10.2 // indirect
Expand All @@ -300,6 +302,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
Expand All @@ -319,6 +322,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/juju/ratelimit v1.0.2 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
Expand Down Expand Up @@ -408,5 +412,6 @@ replace (
github.com/golang/glog => github.com/elastic/glog v1.0.1-0.20210831205241-7d8b5c89dfc4
github.com/google/gopacket => github.com/elastic/gopacket v1.1.20-0.20211202005954-d412fca7f83a
github.com/insomniacslk/dhcp => github.com/elastic/dhcp v0.0.0-20200227161230-57ec251c7eb3 // indirect
github.com/meraki/dashboard-api-go/v3 => github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20240910133632-85f77552ef82
github.com/snowflakedb/gosnowflake => github.com/snowflakedb/gosnowflake v1.6.19
)
15 changes: 15 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,8 @@ github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhO
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8=
github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8=
github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A=
github.com/go-sourcemap/sourcemap v2.1.2+incompatible h1:0b/xya7BKGhXuqFESKM4oIiRo9WOt2ebz7KxfreD6ug=
github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
Expand Down Expand Up @@ -958,6 +960,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
Expand Down Expand Up @@ -1183,6 +1187,8 @@ github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K
github.com/jsternberg/zap-logfmt v1.2.0/go.mod h1:kz+1CUmCutPWABnNkOu9hOHKdT2q3TDYCcsFy9hpqb0=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/juju/ratelimit v1.0.2 h1:sRxmtRiajbvrcLQT7S+JbqU0ntsb9W2yhSdNN8tWfaI=
github.com/juju/ratelimit v1.0.2/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
Expand Down Expand Up @@ -1291,6 +1297,8 @@ github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104/go.mod h1:XPvLUNfbS4f
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/meraki/dashboard-api-go/v3 v3.0.9 h1:l3VIHu+0Jy1GysHe2sSLxp+wVhY6EB2Ng3e8/ygVBXE=
github.com/meraki/dashboard-api-go/v3 v3.0.9/go.mod h1:ngZmCzPKto29KbttUw7ibrLc+5RHHBKihYFkWFrL1zE=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.22/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
Expand Down Expand Up @@ -1629,6 +1637,8 @@ github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYa
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20240910133632-85f77552ef82 h1:HkNKMd1VHxkKojkmXumIFCucJ81IDrW+Fb0/gjavtVA=
github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20240910133632-85f77552ef82/go.mod h1:PS7t/0eK4QVh1lcUTJB/WL9B/Wp8dAHECGWV59f9IY0=
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b h1:X/8hkb4rQq3+QuOxpJK7gWmAXmZucF0EI1s1BfBLq6U=
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b/go.mod h1:jAqhj/JBVC1PwcLTWd6rjQyGyItxxrhpiBl8LSuAGmw=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
Expand Down Expand Up @@ -1816,6 +1826,7 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
Expand Down Expand Up @@ -1958,6 +1969,7 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
Expand Down Expand Up @@ -2110,6 +2122,7 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
Expand All @@ -2123,6 +2136,7 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
Expand Down Expand Up @@ -2153,6 +2167,7 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
2 changes: 2 additions & 0 deletions x-pack/metricbeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions x-pack/metricbeat/module/meraki/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- module: meraki
metricsets: ["appliance_uplinks_status_and_ha"]
enabled: false
period: 10s
hosts: ["localhost"]

2 changes: 2 additions & 0 deletions x-pack/metricbeat/module/meraki/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is the meraki module.

12 changes: 12 additions & 0 deletions x-pack/metricbeat/module/meraki/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- key: meraki
title: "meraki"
release: beta
description: >
Meraki module collects metrics from the meraki api
fields:
- name: meraki
type: group
description: >
Various Meraki metrics
fields:

19 changes: 19 additions & 0 deletions x-pack/metricbeat/module/meraki/device_health/_meta/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"@timestamp":"2016-05-23T08:05:34.853Z",
"beat":{
"hostname":"beathost",
"name":"beathost"
},
"metricset":{
"host":"localhost",
"module":"meraki",
"name":"device_health",
"rtt":44269
},
"meraki":{
"device_health":{
"example": "device_health"
}
},
"type":"metricsets"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the device_health metricset of the module meraki.
15 changes: 15 additions & 0 deletions x-pack/metricbeat/module/meraki/device_health/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- name: device_health
type: group
release: beta
description: >
meraki device_health metricset to collect device metrics
fields:
- name: device
type: group
description: >
meraki devices metrics
fields:
- name: serial
type: number
description: >
unique device serial
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package device_health

import (
"fmt"
"strings"

meraki_api "github.com/meraki/dashboard-api-go/v3/sdk"
)

func getDevicePerformanceScores(client *meraki_api.Client, devices map[Serial]*Device) (map[Serial]*DevicePerformanceScore, error) {

mx_devices := pruneDevicesForMxOnly(devices)

scores := make(map[Serial]*DevicePerformanceScore)
for _, device := range mx_devices {

score_val, score_res, score_err := client.Appliance.GetDeviceAppliancePerformance(device.Serial)
if score_err != nil {
return nil, fmt.Errorf("Appliance.GetDeviceAppliancePerformance failed; %w", score_err)
}

if score_res.StatusCode() != 204 {
scores[Serial(device.Serial)] = &DevicePerformanceScore{
PerformanceScore: *score_val.PerfScore,
HttpStatusCode: 200,
}
}
}

return scores, nil
}

func pruneDevicesForMxOnly(devices map[Serial]*Device) map[Serial]*Device {

mx_devices := make(map[Serial]*Device)
for k, v := range devices {
if strings.Index(v.Model, "MX") == 0 {
mx_devices[k] = v
}
}
return mx_devices
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package device_health

import (
"fmt"

"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/elastic-agent-libs/mapstr"

meraki_api "github.com/meraki/dashboard-api-go/v3/sdk"
)

func reportApplianceUplinkStatuses(reporter mb.ReporterV2, organizationID string, devices map[Serial]*Device, responseApplianceUplinkStatuses *meraki_api.ResponseApplianceGetOrganizationApplianceUplinkStatuses, lossLatencyUplinks []*Uplink) {

metrics := []mapstr.M{}

for _, uplink := range *responseApplianceUplinkStatuses {

if device, ok := devices[Serial(uplink.Serial)]; ok {
metric := mapstr.M{
"uplink.high_availablity.enabled": uplink.HighAvailability.Enabled,
"uplink.high_availablity.role": uplink.HighAvailability.Role,
"uplink.last_reported_at": uplink.LastReportedAt,
"device.address": device.Address,
"device.firmware": device.Firmware,
"device.imei": device.Imei,
"device.lan_ip": device.LanIP,
"device.location": device.Location,
"device.mac": device.Mac,
"device.model": device.Model,
"device.name": device.Name,
"device.network_id": device.NetworkID,
"device.notes": device.Notes,
"device.product_type": device.ProductType,
"device.serial": device.Serial,
"device.tags": device.Tags,
}

for k, v := range device.Details {
metric[fmt.Sprintf("device.details.%s", k)] = v
}

for _, item := range *uplink.Uplinks {

for _, lossLatencyMetric := range lossLatencyUplinks {
if lossLatencyMetric.Interface == item.Interface && string(lossLatencyMetric.DeviceSerial) == device.Serial && lossLatencyMetric.NetworkID == device.NetworkID {
for _, lossLatency := range lossLatencyMetric.Metrics {
//It seems there is bug in the client.Organizations.GetOrganizationDevicesUplinksLossAndLatency code returning differnt IP

Check failure on line 47 in x-pack/metricbeat/module/meraki/device_health/device_appliance_uplink_status_and_ha.go

View workflow job for this annotation

GitHub Actions / lint (windows)

`differnt` is a misspelling of `different` (misspell)
//To mitigate, I am additionally printing the ip as seperate value, IMO it is odd these do not match.

Check failure on line 48 in x-pack/metricbeat/module/meraki/device_health/device_appliance_uplink_status_and_ha.go

View workflow job for this annotation

GitHub Actions / lint (windows)

`seperate` is a misspelling of `separate` (misspell)
// client.Appliance.GetOrganizationApplianceUplinkStatuses
metric["uplink.loss_latancy.ip"] = lossLatencyMetric.IP
metric["uplink.loss_latancy.@timestamp"] = lossLatency.Timestamp
DanH-Semplicity marked this conversation as resolved.
Show resolved Hide resolved
metric["uplink.loss_latancy.loss_percent"] = lossLatency.LossPercent
metric["uplink.loss_latancy.latency_ms"] = lossLatency.LatencyMs

}
}

}
metrics = append(metrics, mapstr.Union(metric, mapstr.M{
"uplink.interface": item.Interface,
"uplink.status": item.Status,
"uplink.ip": item.IP,
"uplink.gateway": item.Gateway,
"uplink.public_ip": item.PublicIP,
"uplink.primary_dns": item.PrimaryDNS,
"uplink.secondary_dns": item.SecondaryDNS,
"uplink.ip_assigned_by": item.IPAssignedBy,
}))

}
}
}

ReportMetricsForOrganization(reporter, organizationID, metrics)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package device_health

import (
"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/elastic-agent-libs/mapstr"

meraki_api "github.com/meraki/dashboard-api-go/v3/sdk"
)

func reportCellularGatewayApplianceUplinkStatuses(reporter mb.ReporterV2, organizationID string, devices map[Serial]*Device, responseCellularGatewayUplinkStatuses *meraki_api.ResponseCellularGatewayGetOrganizationCellularGatewayUplinkStatuses) {

metrics := []mapstr.M{}

for _, uplink := range *responseCellularGatewayUplinkStatuses {

if device, ok := devices[Serial(uplink.Serial)]; ok {
metric := mapstr.M{
"cellular.gateway.uplink.network_id": uplink.NetworkID,
"cellular.gateway.uplink.last_reported_at": uplink.LastReportedAt,
"device.address": device.Address,
"device.firmware": device.Firmware,
"device.imei": device.Imei,
"device.lan_ip": device.LanIP,
"device.location": device.Location,
"device.mac": device.Mac,
"device.model": device.Model,
"device.name": device.Name,
"device.network_id": device.NetworkID,
"device.notes": device.Notes,
"device.product_type": device.ProductType,
"device.serial": device.Serial,
"device.tags": device.Tags,
}

for _, item := range *uplink.Uplinks {
metrics = append(metrics, mapstr.Union(metric, mapstr.M{
"cellular.gateway.uplink.apn": item.Apn,
Copy link
Contributor

Choose a reason for hiding this comment

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

do these need to be named differently from other uplink fields, or are the MG uplinks a distinct concept?

AFAICT the MG uplink metadata is just a superset of the other uplink fields (except 'ip_assigned_by')

"uplink.interface"
"uplink.status"
"uplink.ip"
"uplink.gateway"
"uplink.public_ip"
"uplink.primary_dns"
"uplink.secondary_dns"
"uplink.ip_assigned_by"

------------------

"cellular.gateway.uplink.interface"
"cellular.gateway.uplink.status"
"cellular.gateway.uplink.ip"
"cellular.gateway.uplink.gateway"
"cellular.gateway.uplink.public_ip"
"cellular.gateway.uplink.dns1"
"cellular.gateway.uplink.dns2"

"cellular.gateway.uplink.apn"
"cellular.gateway.uplink.connection_type"
"cellular.gateway.uplink.iccid"
"cellular.gateway.uplink.model"
"cellular.gateway.uplink.provider"
"cellular.gateway.uplink.signal_stat.rsrp"
"cellular.gateway.uplink.signal_stat.rsrq"
"cellular.gateway.uplink.signal_type"

Copy link
Contributor Author

@DanH-Semplicity DanH-Semplicity Sep 13, 2024

Choose a reason for hiding this comment

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

Fair point, I agree the fields looks the same. However, I have already seen where meraki has two unique api calls and same ip address and it is not the same. Also in this case it does appear to be a very unique meraki API call, to completely different code trees (client.Appliance.GetOrganizationApplianceUplinkStatuses() and client.CellularGateway.GetOrganizationCellularGatewayUplinkStatuses()) ... Unless I see the data side by side and returning the exact same data, I am not sure I feel comfortable, assuming the APIs are returning the same values. And even then given two completely different calls, I am not sure I trust their API. If I return what Meraki returns and do not try to merge / combine it, then if there is an issue it is Meraki issue and not MB issue. For the naming pattern ... I was trying to do Object, "cellulargateway" in naming for future debug.

"cellular.gateway.uplink.connection_type": item.ConnectionType,
"cellular.gateway.uplink.dns1": item.DNS1,
"cellular.gateway.uplink.dns2": item.DNS2,
"cellular.gateway.uplink.gateway": item.Gateway,
"cellular.gateway.uplink.iccid": item.Iccid,
"cellular.gateway.uplink.interface": item.Interface,
"cellular.gateway.uplink.ip": item.IP,
"cellular.gateway.uplink.model": item.Model,
"cellular.gateway.uplink.provider": item.Provider,
"cellular.gateway.uplink.public_ip": item.PublicIP,
"cellular.gateway.uplink.signal_stat.rsrp": item.SignalStat.Rsrp,
"cellular.gateway.uplink.signal_stat.rsrq": item.SignalStat.Rsrq,
"cellular.gateway.uplink.signal_type": item.SignalType,
"cellular.gateway.uplink.status": item.Status,
}))

}
}
}
ReportMetricsForOrganization(reporter, organizationID, metrics)
}
Loading
Loading