bluecmd / fortigate_exporter

Prometheus exporter for Fortigate firewalls
GNU General Public License v3.0
227 stars 69 forks source link

FortiSwitch API causing issues with collector returning metrics #288

Open fg-pi opened 2 months ago

fg-pi commented 2 months ago

On the pre-built Grafana dashboard page, there are instructions for updating the Managed Switch collection if running FortiOS 7.2 or higher. "Updated version with Analyzer, Wifi and Switch, please note that in order to get switch data after v. 7.2 you need to edit “managed_switch.go” to look like this: “api/v2/monitor/switch-controller/managed-switch/status”"

I'm running into an issue with the collector after making the change above (due to our firewall running FortiOS 7.4.3).

Prior to modifying "managed_switch.go" and rebuilding, the exporter was returning metrics for everything except the FortiSwitches (which led to chase down the problem and find the note above re: changing the path).

Now when running the exporter, the probe's metrics fail to load at all and instead there are only errors re: switch metric collection:

image

fg-pi commented 1 month ago

I believe I have resolved the issue by changing json:"name" to json:"switch-id" in the Results struct in managed_switch.go. It seems Fortinet changed the naming convention in FortiOS 7.4.3; "switch-id" is the friendly name of the device.

hexionas commented 1 month ago

I've created an MR that should fix this: https://github.com/bluecmd/fortigate_exporter/pull/290