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

Added label: vlanid to system_interface.go #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jseifeddine
Copy link

@jseifeddine jseifeddine commented Feb 9, 2024

Feature add for issue #249

@bluecmd please review 🔢

We have this tested and working in our environment for the last ~6 months, no issues to date.

@jseifeddine jseifeddine force-pushed the feature/add-vlanid-label branch from c8ceb13 to 3714c6d Compare February 9, 2024 11:18
@@ -64,6 +64,7 @@ func probeSystemInterface(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
RxBytes float64 `json:"rx_bytes"`
TxErrors float64 `json:"tx_errors"`
RxErrors float64 `json:"rx_errors"`
VlanID int `json:"vlanid"`
Copy link
Author

@jseifeddine jseifeddine Feb 9, 2024

Choose a reason for hiding this comment

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

json:"vlanid" is an int, I tried keeping as string (for Prometheus metric label), but:

Error: json: cannot unmarshal number into Go struct field ifResult.Results.vlanid of type string

m = append(m, prometheus.MustNewConstMetric(mRxB, prometheus.CounterValue, ir.RxBytes, v.VDOM, ir.Name, ir.Alias, ir.Interface))
m = append(m, prometheus.MustNewConstMetric(mTxErr, prometheus.CounterValue, ir.TxErrors, v.VDOM, ir.Name, ir.Alias, ir.Interface))
m = append(m, prometheus.MustNewConstMetric(mRxErr, prometheus.CounterValue, ir.RxErrors, v.VDOM, ir.Name, ir.Alias, ir.Interface))
vlan_string := strconv.Itoa(ir.VlanID)
Copy link
Author

@jseifeddine jseifeddine Feb 9, 2024

Choose a reason for hiding this comment

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

Prometheus label must be a string, so we convert it before adding to the metric

Copy link
Author

@jseifeddine jseifeddine left a comment

Choose a reason for hiding this comment

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

Added notes

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.

1 participant