Skip to content
Open
Changes from all commits
Commits
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
15 changes: 13 additions & 2 deletions collector/drm_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
drmCardInfo = prometheus.NewDesc(
prometheus.BuildFQName(namespace, drmCollectorSubsystem, "card_info"),
"Card information",
[]string{"card", "memory_vendor", "power_performance_level", "unique_id", "vendor"}, nil,
[]string{"card", "memory_vendor", "power_performance_level", "unique_id", "chip", "vendor"}, nil,
)
Comment thread
SuperQ marked this conversation as resolved.
drmGPUBusyPercent = prometheus.NewDesc(
prometheus.BuildFQName(namespace, drmCollectorSubsystem, "gpu_busy_percent"),
Expand Down Expand Up @@ -96,6 +96,17 @@ func (c *drmCollector) Update(ch chan<- prometheus.Metric) error {
return c.updateAMDCards(ch)
}

func chipName(s sysfs.ClassDRMCardAMDGPUStats) string {
// generate a chip name based on the deviceType and devName
cleanDevName := cleanMetricName(s.DevName)
cleanDevType := cleanMetricName(s.DevType)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should relate to https://github.com/prometheus/node_exporter/blob/master/collector/hwmon_linux.go#L517

However both parts come from different sources and will diverge.
This is annoying after #3646

I am not sure this is something that could actually harm us, but calling it out as an issue overall. Making both implementations align is probably not worth the effort.


if cleanDevType != "" && cleanDevName != "" {
return cleanDevType + "_" + cleanDevName
}
return cleanDevName
}

func (c *drmCollector) updateAMDCards(ch chan<- prometheus.Metric) error {
vendor := "amd"
stats, err := c.fs.ClassDRMCardAMDGPUStats()
Expand All @@ -106,7 +117,7 @@ func (c *drmCollector) updateAMDCards(ch chan<- prometheus.Metric) error {
for _, s := range stats {
ch <- prometheus.MustNewConstMetric(
drmCardInfo, prometheus.GaugeValue, 1,
s.Name, s.MemoryVRAMVendor, s.PowerDPMForcePerformanceLevel, s.UniqueID, vendor)
Comment thread
SuperQ marked this conversation as resolved.
s.Name, s.MemoryVRAMVendor, s.PowerDPMForcePerformanceLevel, s.UniqueID, chipName(s), vendor)

ch <- prometheus.MustNewConstMetric(
drmGPUBusyPercent, prometheus.GaugeValue, float64(s.GPUBusyPercent), s.Name)
Expand Down