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

feat(probe): Fortiswitch port stats #219

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Jurka007
Copy link

@bluecmd
Copy link
Owner

bluecmd commented Jul 17, 2023

@Jurka007 can you rebase and fix the check errors?

@bluecmd bluecmd changed the title Fortiswitch port stats feat(probe): Fortiswitch port stats Jul 18, 2023
Copy link
Owner

@bluecmd bluecmd left a comment

Choose a reason for hiding this comment

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

Some metric naming and label comments

* `fortiswitch_port_receive_drops_total`
* `fortiswitch_port_receive_oversized_packets_total`
* _SwitchController/ManageSwitch/Health_
* `fortiswitch_health_summary_cpu`
Copy link
Owner

Choose a reason for hiding this comment

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

  • Avoid using words like mem when memory works
  • These health metrics names have no unit in them (e.g. add _celsius tofortiswitch_health_temperature

VDOM string
}
var r swResponse
//var r map[string]swResponse
Copy link
Owner

Choose a reason for hiding this comment

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

Remove dead code

mSumCPU = prometheus.NewDesc(
"fortiswitch_health_summary_cpu",
"Summary CPU health",
[]string{"rating", "fortiswitch", "VDOM"}, nil,
Copy link
Owner

Choose a reason for hiding this comment

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

Lowercase all labels

//for _, sw := range r {
for fswitch, hr := range r.Results {

m = append(m, prometheus.MustNewConstMetric(mSumCPU, prometheus.GaugeValue, hr.Summary.CPU.Value, hr.Summary.CPU.Rating, fswitch, r.VDOM))
Copy link
Owner

Choose a reason for hiding this comment

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

The rating likely shouldn't be a level ä label but rather a metric like "xxx_is_good". That, or an enum label on a _rating metric. Otherwise it's really hard to use it in alerts.

)
mSumUpTime = prometheus.NewDesc(
"fortiswitch_health_summary_uptime",
"Summary Uptime",
Copy link
Owner

Choose a reason for hiding this comment

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

If you have the documentation it would be really great if these descriptions could be made more verbose so I for example have any idea what these means. But if you don't, it's fine - sometimes we simply don't know

}
m = append(m, prometheus.MustNewConstMetric(mPortStatus, prometheus.GaugeValue, pStatus, swr.VDOM, swr.Name, pi.Interface, pi.Vlan, pi.Duplex))
m = append(m, prometheus.MustNewConstMetric(mPortSpeed, prometheus.GaugeValue, pi.Speed*1000*1000, swr.VDOM, swr.Name, pi.Interface, pi.Vlan, pi.Duplex))

Copy link
Owner

Choose a reason for hiding this comment

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

Having duplex as a label seems a bit off to me. Why not have it as a separate metric?

if swr.Status == "Connected" {
swStatus = 1.0
}
m = append(m, prometheus.MustNewConstMetric(mSwitchStatus, prometheus.GaugeValue, swStatus, swr.VDOM, swr.Name, swr.FgPeerIntfName, swr.Connection, swr.State))
Copy link
Owner

Choose a reason for hiding this comment

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

The state label here should likely be an enum label if the possible values of state is limited and known. It's hard to use it for anything useful otherwise.

mPortStatus = prometheus.NewDesc(
"fortiswitch_port_status",
"Whether the switch port is up or not",
[]string{"vdom", "name", "interface", "vlan", "duplex"}, nil,
Copy link
Owner

Choose a reason for hiding this comment

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

Can a port only have one VLAN on a
Fortiswitch? That seems odd. What happens when the port is a VLAN trunk?

mSwitchStatus = prometheus.NewDesc(
"fortiswitch_status",
"Whether the switch is connected or not",
[]string{"vdom", "name", "fgt_peer_intf_name", "connection_from", "state"}, nil,
Copy link
Owner

Choose a reason for hiding this comment

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

This meric is not like the rest. The fgt_peer_intf_name and connection_from is not clear to me what this metric is. Care to add it to the description or as a comment in code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants