-
Notifications
You must be signed in to change notification settings - Fork 18
PMM-7 procfs migration to v0.15.1 #220
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
Changes from all commits
bbf63b5
f4eaca3
005e830
0415ab8
1c03aeb
1e7ae10
018b44f
adfb543
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "github.com/go-kit/log" | ||
| "github.com/go-kit/log/level" | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| "github.com/prometheus/node_exporter/collector/utils" | ||
| "github.com/prometheus/procfs/sysfs" | ||
| ) | ||
|
|
||
|
|
@@ -114,23 +115,36 @@ func (c *fibrechannelCollector) Update(ch chan<- prometheus.Metric) error { | |
| infoValue := 1.0 | ||
|
|
||
| // First push the Host values | ||
| ch <- prometheus.MustNewConstMetric(infoDesc, prometheus.GaugeValue, infoValue, host.Name, host.Speed, host.PortState, host.PortType, host.PortID, host.PortName, host.FabricName, host.SymbolicName, host.SupportedClasses, host.SupportedSpeeds, host.DevLossTMO) | ||
| ch <- prometheus.MustNewConstMetric(infoDesc, prometheus.GaugeValue, infoValue, utils.SafeDereference( | ||
| host.Name, | ||
| host.Speed, | ||
| host.PortState, | ||
| host.PortType, | ||
| host.PortID, | ||
| host.PortName, | ||
| host.FabricName, | ||
| host.SymbolicName, | ||
| host.SupportedClasses, | ||
| host.SupportedSpeeds, | ||
| host.DevLossTMO, | ||
| )...) | ||
|
|
||
| // Then the counters | ||
| c.pushCounter(ch, "dumped_frames_total", host.Counters.DumpedFrames, host.Name) | ||
| c.pushCounter(ch, "error_frames_total", host.Counters.ErrorFrames, host.Name) | ||
| c.pushCounter(ch, "invalid_crc_total", host.Counters.InvalidCRCCount, host.Name) | ||
| c.pushCounter(ch, "rx_frames_total", host.Counters.RXFrames, host.Name) | ||
| c.pushCounter(ch, "rx_words_total", host.Counters.RXWords, host.Name) | ||
| c.pushCounter(ch, "tx_frames_total", host.Counters.TXFrames, host.Name) | ||
| c.pushCounter(ch, "tx_words_total", host.Counters.TXWords, host.Name) | ||
| c.pushCounter(ch, "seconds_since_last_reset_total", host.Counters.SecondsSinceLastReset, host.Name) | ||
| c.pushCounter(ch, "invalid_tx_words_total", host.Counters.InvalidTXWordCount, host.Name) | ||
| c.pushCounter(ch, "link_failure_total", host.Counters.LinkFailureCount, host.Name) | ||
| c.pushCounter(ch, "loss_of_sync_total", host.Counters.LossOfSyncCount, host.Name) | ||
| c.pushCounter(ch, "loss_of_signal_total", host.Counters.LossOfSignalCount, host.Name) | ||
| c.pushCounter(ch, "nos_total", host.Counters.NosCount, host.Name) | ||
| c.pushCounter(ch, "fcp_packet_aborts_total", host.Counters.FCPPacketAborts, host.Name) | ||
| // Note: `procfs` guarantees these a safe dereference for these counters. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We restore a bad attempt to fix the issue in a prior commit, so it now matches the usptream. |
||
| c.pushCounter(ch, "dumped_frames_total", *host.Counters.DumpedFrames, *host.Name) | ||
| c.pushCounter(ch, "error_frames_total", *host.Counters.ErrorFrames, *host.Name) | ||
| c.pushCounter(ch, "invalid_crc_total", *host.Counters.InvalidCRCCount, *host.Name) | ||
| c.pushCounter(ch, "rx_frames_total", *host.Counters.RXFrames, *host.Name) | ||
| c.pushCounter(ch, "rx_words_total", *host.Counters.RXWords, *host.Name) | ||
| c.pushCounter(ch, "tx_frames_total", *host.Counters.TXFrames, *host.Name) | ||
| c.pushCounter(ch, "tx_words_total", *host.Counters.TXWords, *host.Name) | ||
| c.pushCounter(ch, "seconds_since_last_reset_total", *host.Counters.SecondsSinceLastReset, *host.Name) | ||
| c.pushCounter(ch, "invalid_tx_words_total", *host.Counters.InvalidTXWordCount, *host.Name) | ||
| c.pushCounter(ch, "link_failure_total", *host.Counters.LinkFailureCount, *host.Name) | ||
| c.pushCounter(ch, "loss_of_sync_total", *host.Counters.LossOfSyncCount, *host.Name) | ||
| c.pushCounter(ch, "loss_of_signal_total", *host.Counters.LossOfSignalCount, *host.Name) | ||
| c.pushCounter(ch, "nos_total", *host.Counters.NosCount, *host.Name) | ||
| c.pushCounter(ch, "fcp_packet_aborts_total", *host.Counters.FCPPacketAborts, *host.Name) | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -538,15 +538,16 @@ func (c *mountStatsCollector) Update(ch chan<- prometheus.Metric) error { | |
| mountAddress = miStats.SuperOptions["addr"] | ||
| } | ||
|
|
||
| deviceIdentifier := nfsDeviceIdentifier{m.Device, stats.Transport.Protocol, mountAddress} | ||
| i := deviceList[deviceIdentifier] | ||
| if i { | ||
| level.Debug(c.logger).Log("msg", "Skipping duplicate device entry", "device", deviceIdentifier) | ||
| continue | ||
| for k := range stats.Transport { | ||
| deviceIdentifier := nfsDeviceIdentifier{m.Device, stats.Transport[k].Protocol, mountAddress} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the breaking change from upstream (in minor version!). |
||
| i := deviceList[deviceIdentifier] | ||
| if i { | ||
| level.Debug(c.logger).Log("msg", "Skipping duplicate device entry", "device", deviceIdentifier) | ||
| break | ||
| } | ||
| deviceList[deviceIdentifier] = true | ||
| c.updateNFSStats(ch, stats, m.Device, stats.Transport[k].Protocol, mountAddress) | ||
| } | ||
|
|
||
| deviceList[deviceIdentifier] = true | ||
| c.updateNFSStats(ch, stats, m.Device, stats.Transport.Protocol, mountAddress) | ||
| } | ||
|
|
||
| return nil | ||
|
|
@@ -617,75 +618,77 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, s *pro | |
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportBindTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.Bind), | ||
| labelValues..., | ||
| ) | ||
| for i := range s.Transport { | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportBindTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].Bind), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportConnectTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.Connect), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportConnectTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].Connect), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportIdleTimeSeconds, | ||
| prometheus.GaugeValue, | ||
| float64(s.Transport.IdleTimeSeconds%float64Mantissa), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportIdleTimeSeconds, | ||
| prometheus.GaugeValue, | ||
| float64(s.Transport[i].IdleTimeSeconds%float64Mantissa), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportSendsTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.Sends), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportSendsTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].Sends), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportReceivesTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.Receives), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportReceivesTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].Receives), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportBadTransactionIDsTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.BadTransactionIDs), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportBadTransactionIDsTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].BadTransactionIDs), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportBacklogQueueTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.CumulativeBacklog), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportBacklogQueueTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].CumulativeBacklog), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportMaximumRPCSlots, | ||
| prometheus.GaugeValue, | ||
| float64(s.Transport.MaximumRPCSlotsUsed), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportMaximumRPCSlots, | ||
| prometheus.GaugeValue, | ||
| float64(s.Transport[i].MaximumRPCSlotsUsed), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportSendingQueueTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.CumulativeSendingQueue), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportSendingQueueTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].CumulativeSendingQueue), | ||
| labelValues..., | ||
| ) | ||
|
|
||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportPendingQueueTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport.CumulativePendingQueue), | ||
| labelValues..., | ||
| ) | ||
| ch <- prometheus.MustNewConstMetric( | ||
| c.NFSTransportPendingQueueTotal, | ||
| prometheus.CounterValue, | ||
| float64(s.Transport[i].CumulativePendingQueue), | ||
| labelValues..., | ||
| ) | ||
| } | ||
|
|
||
| for _, op := range s.Operations { | ||
| opLabelValues := []string{export, protocol, mountAddress, op.Operation} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright 2024 The Prometheus Authors | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package utils | ||
|
|
||
| func SafeDereference[T any](s ...*T) []T { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is taken from upstream so we don't run into conflicts when rebasing. |
||
| var resolved []T | ||
| for _, v := range s { | ||
| if v != nil { | ||
| resolved = append(resolved, *v) | ||
| } else { | ||
| var zeroValue T | ||
| resolved = append(resolved, zeroValue) | ||
| } | ||
| } | ||
| return resolved | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was missed in the migration to v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current version is 2.12.2