Просмотр исходного кода

KCM-4229: Ingesting Collector Diagnostics to bucket (#3221)

Signed-off-by: Ishaan Mittal <ishaanmittal123@gmail.com>
Ishaan Mittal 10 месяцев назад
Родитель
Сommit
033c0ca43a

+ 72 - 73
modules/collector-source/pkg/collector/collector.go

@@ -4,7 +4,6 @@ import (
 	"github.com/opencost/opencost/core/pkg/source"
 	"github.com/opencost/opencost/modules/collector-source/pkg/metric"
 	"github.com/opencost/opencost/modules/collector-source/pkg/metric/aggregator"
-	"github.com/opencost/opencost/modules/collector-source/pkg/scrape"
 )
 
 // NewOpenCostMetricStore creates a new MetricStore which has registered all MetricCollector instances required
@@ -100,7 +99,7 @@ func NewOpenCostMetricStore() metric.MetricStore {
 func NewPVPricePerGiBHourMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVPricePerGiBHourID,
-		scrape.PVHourlyCost,
+		metric.PVHourlyCost,
 		[]string{
 			source.VolumeNameLabel,
 			source.PVLabel,
@@ -122,7 +121,7 @@ func NewPVPricePerGiBHourMetricCollector() *metric.MetricCollector {
 func NewPVUsedAverageMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVUsedAverageID,
-		scrape.KubeletVolumeStatsUsedBytes,
+		metric.KubeletVolumeStatsUsedBytes,
 		[]string{
 			source.NamespaceLabel,
 			source.PVCLabel,
@@ -143,7 +142,7 @@ func NewPVUsedAverageMetricCollector() *metric.MetricCollector {
 func NewPVUsedMaxMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVUsedMaxID,
-		scrape.KubeletVolumeStatsUsedBytes,
+		metric.KubeletVolumeStatsUsedBytes,
 		[]string{
 			source.NamespaceLabel,
 			source.PVCLabel,
@@ -163,7 +162,7 @@ func NewPVUsedMaxMetricCollector() *metric.MetricCollector {
 func NewPVCInfoMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVCInfoID,
-		scrape.KubePersistentVolumeClaimInfo,
+		metric.KubePersistentVolumeClaimInfo,
 		[]string{
 			source.NamespaceLabel,
 			source.VolumeNameLabel,
@@ -186,7 +185,7 @@ func NewPVCInfoMetricCollector() *metric.MetricCollector {
 func NewPVActiveMinutesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVActiveMinutesID,
-		scrape.KubePersistentVolumeCapacityBytes,
+		metric.KubePersistentVolumeCapacityBytes,
 		[]string{
 			source.PVLabel,
 		},
@@ -211,7 +210,7 @@ func NewPVActiveMinutesMetricCollector() *metric.MetricCollector {
 func NewLocalStorageUsedActiveMinutesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.LocalStorageUsedActiveMinutesID,
-		scrape.ContainerFSUsageBytes,
+		metric.ContainerFSUsageBytes,
 		[]string{
 			source.InstanceLabel,
 			source.DeviceLabel,
@@ -236,7 +235,7 @@ func NewLocalStorageUsedActiveMinutesMetricCollector() *metric.MetricCollector {
 func NewLocalStorageUsedAverageMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.LocalStorageUsedAverageID,
-		scrape.ContainerFSUsageBytes,
+		metric.ContainerFSUsageBytes,
 		[]string{
 			source.InstanceLabel,
 			source.DeviceLabel,
@@ -262,7 +261,7 @@ func NewLocalStorageUsedAverageMetricCollector() *metric.MetricCollector {
 func NewLocalStorageUsedMaxMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.LocalStorageUsedMaxID,
-		scrape.ContainerFSUsageBytes,
+		metric.ContainerFSUsageBytes,
 		[]string{
 			source.InstanceLabel,
 			source.DeviceLabel,
@@ -286,7 +285,7 @@ func NewLocalStorageUsedMaxMetricCollector() *metric.MetricCollector {
 func NewLocalStorageBytesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.LocalStorageBytesID,
-		scrape.NodeFSCapacityBytes,
+		metric.NodeFSCapacityBytes,
 		[]string{
 			source.InstanceLabel,
 			source.DeviceLabel,
@@ -306,7 +305,7 @@ func NewLocalStorageBytesMetricCollector() *metric.MetricCollector {
 func NewLocalStorageActiveMinutesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.LocalStorageActiveMinutesID,
-		scrape.NodeTotalHourlyCost,
+		metric.NodeTotalHourlyCost,
 		[]string{
 			source.NodeLabel,
 			source.ProviderIDLabel,
@@ -328,7 +327,7 @@ func NewLocalStorageActiveMinutesMetricCollector() *metric.MetricCollector {
 func NewNodeCPUCoresCapacityMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeCPUCoresCapacityID,
-		scrape.KubeNodeStatusCapacityCPUCores,
+		metric.KubeNodeStatusCapacityCPUCores,
 		[]string{
 			source.NodeLabel,
 		},
@@ -348,7 +347,7 @@ func NewNodeCPUCoresCapacityMetricCollector() *metric.MetricCollector {
 func NewNodeCPUCoresAllocatableMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeCPUCoresAllocatableID,
-		scrape.KubeNodeStatusAllocatableCPUCores,
+		metric.KubeNodeStatusAllocatableCPUCores,
 		[]string{
 			source.NodeLabel,
 		},
@@ -368,7 +367,7 @@ func NewNodeCPUCoresAllocatableMetricCollector() *metric.MetricCollector {
 func NewNodeRAMBytesCapacityMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeRAMBytesCapacityID,
-		scrape.KubeNodeStatusCapacityMemoryBytes,
+		metric.KubeNodeStatusCapacityMemoryBytes,
 		[]string{
 			source.NodeLabel,
 		},
@@ -388,7 +387,7 @@ func NewNodeRAMBytesCapacityMetricCollector() *metric.MetricCollector {
 func NewNodeRAMBytesAllocatableMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeRAMBytesAllocatableID,
-		scrape.KubeNodeStatusAllocatableMemoryBytes,
+		metric.KubeNodeStatusAllocatableMemoryBytes,
 		[]string{
 			source.NodeLabel,
 		},
@@ -408,7 +407,7 @@ func NewNodeRAMBytesAllocatableMetricCollector() *metric.MetricCollector {
 func NewNodeGPUCountMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeGPUCountID,
-		scrape.NodeGPUCount,
+		metric.NodeGPUCount,
 		[]string{
 			source.NodeLabel,
 			source.ProviderIDLabel,
@@ -427,7 +426,7 @@ func NewNodeGPUCountMetricCollector() *metric.MetricCollector {
 func NewNodeLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeLabelsID,
-		scrape.KubeNodeLabels,
+		metric.KubeNodeLabels,
 		[]string{
 			source.NodeLabel,
 		},
@@ -445,7 +444,7 @@ func NewNodeLabelsMetricCollector() *metric.MetricCollector {
 func NewNodeActiveMinutesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeActiveMinutesID,
-		scrape.NodeTotalHourlyCost,
+		metric.NodeTotalHourlyCost,
 		[]string{
 			source.NodeLabel,
 			source.ProviderIDLabel,
@@ -466,7 +465,7 @@ func NewNodeActiveMinutesMetricCollector() *metric.MetricCollector {
 func NewNodeCPUModeTotalMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeCPUModeTotalID,
-		scrape.NodeCPUSecondsTotal,
+		metric.NodeCPUSecondsTotal,
 		[]string{
 			source.KubernetesNodeLabel,
 			source.ModeLabel,
@@ -490,7 +489,7 @@ func NewNodeCPUModeTotalMetricCollector() *metric.MetricCollector {
 func NewNodeRAMSystemUsageAverageMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeRAMSystemUsageAverageID,
-		scrape.ContainerMemoryWorkingSetBytes,
+		metric.ContainerMemoryWorkingSetBytes,
 		[]string{
 			source.InstanceLabel,
 		},
@@ -515,7 +514,7 @@ func NewNodeRAMSystemUsageAverageMetricCollector() *metric.MetricCollector {
 func NewNodeRAMUserUsageAverageMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeRAMUserUsageAverageID,
-		scrape.ContainerMemoryWorkingSetBytes,
+		metric.ContainerMemoryWorkingSetBytes,
 		[]string{
 			source.InstanceLabel,
 		},
@@ -537,7 +536,7 @@ func NewNodeRAMUserUsageAverageMetricCollector() *metric.MetricCollector {
 func NewLBPricePerHourMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.LBPricePerHourID,
-		scrape.KubecostLoadBalancerCost,
+		metric.KubecostLoadBalancerCost,
 		[]string{
 			source.NamespaceLabel,
 			source.ServiceNameLabel,
@@ -557,7 +556,7 @@ func NewLBPricePerHourMetricCollector() *metric.MetricCollector {
 func NewLBActiveMinutesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.LBActiveMinutesID,
-		scrape.KubecostLoadBalancerCost,
+		metric.KubecostLoadBalancerCost,
 		[]string{
 			source.NamespaceLabel,
 			source.ServiceNameLabel,
@@ -577,7 +576,7 @@ func NewLBActiveMinutesMetricCollector() *metric.MetricCollector {
 func NewClusterManagementDurationMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.ClusterManagementDurationID,
-		scrape.KubecostClusterManagementCost,
+		metric.KubecostClusterManagementCost,
 		[]string{
 			source.ProvisionerNameLabel,
 		},
@@ -597,7 +596,7 @@ func NewClusterManagementDurationMetricCollector() *metric.MetricCollector {
 func NewClusterManagementPricePerHourMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.ClusterManagementPricePerHourID,
-		scrape.KubecostClusterManagementCost,
+		metric.KubecostClusterManagementCost,
 		[]string{
 			source.ProvisionerNameLabel,
 		},
@@ -615,7 +614,7 @@ func NewClusterManagementPricePerHourMetricCollector() *metric.MetricCollector {
 func NewPodActiveMinutesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PodActiveMinutesID,
-		scrape.KubePodContainerStatusRunning,
+		metric.KubePodContainerStatusRunning,
 		[]string{
 			source.UIDLabel,
 			source.NamespaceLabel,
@@ -640,7 +639,7 @@ func NewPodActiveMinutesMetricCollector() *metric.MetricCollector {
 func NewRAMBytesAllocatedMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.RAMBytesAllocatedID,
-		scrape.ContainerMemoryAllocationBytes,
+		metric.ContainerMemoryAllocationBytes,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -671,7 +670,7 @@ func NewRAMBytesAllocatedMetricCollector() *metric.MetricCollector {
 func NewRAMRequestsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.RAMRequestsID,
-		scrape.KubePodContainerResourceRequests,
+		metric.KubePodContainerResourceRequests,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -699,7 +698,7 @@ func NewRAMRequestsMetricCollector() *metric.MetricCollector {
 func NewRAMUsageAverageMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.RAMUsageAverageID,
-		scrape.ContainerMemoryWorkingSetBytes,
+		metric.ContainerMemoryWorkingSetBytes,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -728,7 +727,7 @@ func NewRAMUsageAverageMetricCollector() *metric.MetricCollector {
 func NewRAMUsageMaxMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.RAMUsageMaxID,
-		scrape.ContainerMemoryWorkingSetBytes,
+		metric.ContainerMemoryWorkingSetBytes,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -757,7 +756,7 @@ func NewRAMUsageMaxMetricCollector() *metric.MetricCollector {
 func NewCPUCoresAllocatedMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.CPUCoresAllocatedID,
-		scrape.ContainerCPUAllocation,
+		metric.ContainerCPUAllocation,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -788,7 +787,7 @@ func NewCPUCoresAllocatedMetricCollector() *metric.MetricCollector {
 func NewCPURequestsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.CPURequestsID,
-		scrape.KubePodContainerResourceRequests,
+		metric.KubePodContainerResourceRequests,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -817,7 +816,7 @@ func NewCPURequestsMetricCollector() *metric.MetricCollector {
 func NewCPUUsageAverageMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.CPUUsageAverageID,
-		scrape.ContainerCPUUsageSecondsTotal,
+		metric.ContainerCPUUsageSecondsTotal,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -848,7 +847,7 @@ func NewCPUUsageAverageMetricCollector() *metric.MetricCollector {
 func NewCPUUsageMaxMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.CPUUsageMaxID,
-		scrape.ContainerCPUUsageSecondsTotal,
+		metric.ContainerCPUUsageSecondsTotal,
 		[]string{
 			source.NodeLabel,
 			source.InstanceLabel,
@@ -878,7 +877,7 @@ func NewCPUUsageMaxMetricCollector() *metric.MetricCollector {
 func NewGPUsRequestedMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.GPUsRequestedID,
-		scrape.KubePodContainerResourceRequests,
+		metric.KubePodContainerResourceRequests,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -902,7 +901,7 @@ func NewGPUsRequestedMetricCollector() *metric.MetricCollector {
 func NewGPUsUsageAverageMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.GPUsUsageAverageID,
-		scrape.DCGMFIPROFGRENGINEACTIVE,
+		metric.DCGMFIPROFGRENGINEACTIVE,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -926,7 +925,7 @@ func NewGPUsUsageAverageMetricCollector() *metric.MetricCollector {
 func NewGPUsUsageMaxMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.GPUsUsageMaxID,
-		scrape.DCGMFIPROFGRENGINEACTIVE,
+		metric.DCGMFIPROFGRENGINEACTIVE,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -953,7 +952,7 @@ func NewGPUsUsageMaxMetricCollector() *metric.MetricCollector {
 func NewGPUsAllocatedMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.GPUsAllocatedID,
-		scrape.ContainerGPUAllocation,
+		metric.ContainerGPUAllocation,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -982,7 +981,7 @@ func NewGPUsAllocatedMetricCollector() *metric.MetricCollector {
 func NewIsGPUSharedMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.IsGPUSharedID,
-		scrape.KubePodContainerResourceRequests,
+		metric.KubePodContainerResourceRequests,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1008,7 +1007,7 @@ func NewIsGPUSharedMetricCollector() *metric.MetricCollector {
 func NewGPUInfoMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.GPUInfoID,
-		scrape.DCGMFIDEVDECUTIL,
+		metric.DCGMFIDEVDECUTIL,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1035,7 +1034,7 @@ func NewGPUInfoMetricCollector() *metric.MetricCollector {
 func NewNodeCPUPricePerHourMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeCPUPricePerHourID,
-		scrape.NodeCPUHourlyCost,
+		metric.NodeCPUHourlyCost,
 		[]string{
 			source.NodeLabel,
 			source.InstanceTypeLabel,
@@ -1057,7 +1056,7 @@ func NewNodeCPUPricePerHourMetricCollector() *metric.MetricCollector {
 func NewNodeRAMPricePerGiBHourMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeRAMPricePerGiBHourID,
-		scrape.NodeRAMHourlyCost,
+		metric.NodeRAMHourlyCost,
 		[]string{
 			source.NodeLabel,
 			source.InstanceTypeLabel,
@@ -1079,7 +1078,7 @@ func NewNodeRAMPricePerGiBHourMetricCollector() *metric.MetricCollector {
 func NewNodeGPUPricePerHourMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeGPUPricePerHourID,
-		scrape.NodeGPUHourlyCost,
+		metric.NodeGPUHourlyCost,
 		[]string{
 			source.NodeLabel,
 			source.InstanceTypeLabel,
@@ -1099,7 +1098,7 @@ func NewNodeGPUPricePerHourMetricCollector() *metric.MetricCollector {
 func NewNodeIsSpotMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NodeIsSpotID,
-		scrape.KubecostNodeIsSpot,
+		metric.KubecostNodeIsSpot,
 		[]string{
 			source.NodeLabel,
 			source.ProviderIDLabel,
@@ -1120,7 +1119,7 @@ func NewNodeIsSpotMetricCollector() *metric.MetricCollector {
 func NewPodPVCAllocationMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PodPVCAllocationID,
-		scrape.PodPVCAllocation,
+		metric.PodPVCAllocation,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1143,7 +1142,7 @@ func NewPodPVCAllocationMetricCollector() *metric.MetricCollector {
 func NewPVCBytesRequestedMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVCBytesRequestedID,
-		scrape.KubePersistentVolumeClaimResourceRequestsStorageBytes,
+		metric.KubePersistentVolumeClaimResourceRequestsStorageBytes,
 		[]string{
 			source.NamespaceLabel,
 			source.PVCLabel,
@@ -1164,7 +1163,7 @@ func NewPVCBytesRequestedMetricCollector() *metric.MetricCollector {
 func NewPVBytesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVBytesID,
-		scrape.KubePersistentVolumeCapacityBytes,
+		metric.KubePersistentVolumeCapacityBytes,
 		[]string{
 			source.PVLabel,
 		},
@@ -1184,7 +1183,7 @@ func NewPVBytesMetricCollector() *metric.MetricCollector {
 func NewPVInfoMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PVInfoID,
-		scrape.KubecostPVInfo,
+		metric.KubecostPVInfo,
 		[]string{
 			source.PVLabel,
 			source.StorageClassLabel,
@@ -1210,7 +1209,7 @@ func NewPVInfoMetricCollector() *metric.MetricCollector {
 func NewNetZoneGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetZoneGiBID,
-		scrape.KubecostPodNetworkEgressBytesTotal,
+		metric.KubecostPodNetworkEgressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1234,7 +1233,7 @@ func NewNetZoneGiBMetricCollector() *metric.MetricCollector {
 func NewNetZonePricePerGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetZonePricePerGiBID,
-		scrape.KubecostNetworkZoneEgressCost,
+		metric.KubecostNetworkZoneEgressCost,
 		[]string{},
 		aggregator.AverageOverTime,
 		nil,
@@ -1255,7 +1254,7 @@ func NewNetZonePricePerGiBMetricCollector() *metric.MetricCollector {
 func NewNetRegionGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetRegionGiBID,
-		scrape.KubecostPodNetworkEgressBytesTotal,
+		metric.KubecostPodNetworkEgressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1278,7 +1277,7 @@ func NewNetRegionGiBMetricCollector() *metric.MetricCollector {
 func NewNetRegionPricePerGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetRegionPricePerGiBID,
-		scrape.KubecostNetworkRegionEgressCost,
+		metric.KubecostNetworkRegionEgressCost,
 		[]string{},
 		aggregator.AverageOverTime,
 		nil,
@@ -1297,7 +1296,7 @@ func NewNetRegionPricePerGiBMetricCollector() *metric.MetricCollector {
 func NewNetInternetGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetInternetGiBID,
-		scrape.KubecostPodNetworkEgressBytesTotal,
+		metric.KubecostPodNetworkEgressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1320,7 +1319,7 @@ func NewNetInternetGiBMetricCollector() *metric.MetricCollector {
 func NewNetInternetPricePerGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetInternetPricePerGiBID,
-		scrape.KubecostNetworkInternetEgressCost,
+		metric.KubecostNetworkInternetEgressCost,
 		[]string{},
 		aggregator.AverageOverTime,
 		nil,
@@ -1339,7 +1338,7 @@ func NewNetInternetPricePerGiBMetricCollector() *metric.MetricCollector {
 func NewNetInternetServiceGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetInternetServiceGiBID,
-		scrape.KubecostPodNetworkEgressBytesTotal,
+		metric.KubecostPodNetworkEgressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1364,7 +1363,7 @@ func NewNetInternetServiceGiBMetricCollector() *metric.MetricCollector {
 func NewNetReceiveBytesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetReceiveBytesID,
-		scrape.ContainerNetworkReceiveBytesTotal,
+		metric.ContainerNetworkReceiveBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1390,7 +1389,7 @@ func NewNetReceiveBytesMetricCollector() *metric.MetricCollector {
 func NewNetZoneIngressGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetZoneIngressGiBID,
-		scrape.KubecostPodNetworkIngressBytesTotal,
+		metric.KubecostPodNetworkIngressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1418,7 +1417,7 @@ func NewNetZoneIngressGiBMetricCollector() *metric.MetricCollector {
 func NewNetRegionIngressGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetRegionIngressGiBID,
-		scrape.KubecostPodNetworkIngressBytesTotal,
+		metric.KubecostPodNetworkIngressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1444,7 +1443,7 @@ func NewNetRegionIngressGiBMetricCollector() *metric.MetricCollector {
 func NewNetInternetIngressGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetInternetIngressGiBID,
-		scrape.KubecostPodNetworkIngressBytesTotal,
+		metric.KubecostPodNetworkIngressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1468,7 +1467,7 @@ func NewNetInternetIngressGiBMetricCollector() *metric.MetricCollector {
 func NewNetInternetServiceIngressGiBMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetInternetServiceIngressGiBID,
-		scrape.KubecostPodNetworkIngressBytesTotal,
+		metric.KubecostPodNetworkIngressBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodNameLabel,
@@ -1493,7 +1492,7 @@ func NewNetInternetServiceIngressGiBMetricCollector() *metric.MetricCollector {
 func NewNetTransferBytesMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NetTransferBytesID,
-		scrape.ContainerNetworkTransmitBytesTotal,
+		metric.ContainerNetworkTransmitBytesTotal,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1514,7 +1513,7 @@ func NewNetTransferBytesMetricCollector() *metric.MetricCollector {
 func NewNamespaceLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NamespaceLabelsID,
-		scrape.KubeNamespaceLabels,
+		metric.KubeNamespaceLabels,
 		[]string{
 			source.NamespaceLabel,
 		},
@@ -1532,7 +1531,7 @@ func NewNamespaceLabelsMetricCollector() *metric.MetricCollector {
 func NewNamespaceAnnotationsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.NamespaceAnnotationsID,
-		scrape.KubeNamespaceAnnotations,
+		metric.KubeNamespaceAnnotations,
 		[]string{
 			source.NamespaceLabel,
 		},
@@ -1550,7 +1549,7 @@ func NewNamespaceAnnotationsMetricCollector() *metric.MetricCollector {
 func NewPodLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PodLabelsID,
-		scrape.KubePodLabels,
+		metric.KubePodLabels,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1569,7 +1568,7 @@ func NewPodLabelsMetricCollector() *metric.MetricCollector {
 func NewPodAnnotationsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PodAnnotationsID,
-		scrape.KubePodAnnotations,
+		metric.KubePodAnnotations,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1588,7 +1587,7 @@ func NewPodAnnotationsMetricCollector() *metric.MetricCollector {
 func NewServiceLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.ServiceLabelsID,
-		scrape.ServiceSelectorLabels,
+		metric.ServiceSelectorLabels,
 		[]string{
 			source.NamespaceLabel,
 			source.ServiceLabel,
@@ -1607,7 +1606,7 @@ func NewServiceLabelsMetricCollector() *metric.MetricCollector {
 func NewDeploymentLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.DeploymentLabelsID,
-		scrape.DeploymentMatchLabels,
+		metric.DeploymentMatchLabels,
 		[]string{
 			source.NamespaceLabel,
 			source.DeploymentLabel,
@@ -1626,7 +1625,7 @@ func NewDeploymentLabelsMetricCollector() *metric.MetricCollector {
 func NewStatefulSetLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.StatefulSetLabelsID,
-		scrape.StatefulSetMatchLabels,
+		metric.StatefulSetMatchLabels,
 		[]string{
 			source.NamespaceLabel,
 			source.StatefulSetLabel,
@@ -1648,7 +1647,7 @@ func NewStatefulSetLabelsMetricCollector() *metric.MetricCollector {
 func NewDaemonSetLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.DaemonSetLabelsID,
-		scrape.KubePodOwner,
+		metric.KubePodOwner,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1673,7 +1672,7 @@ func NewDaemonSetLabelsMetricCollector() *metric.MetricCollector {
 func NewJobLabelsMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.JobLabelsID,
-		scrape.KubePodOwner,
+		metric.KubePodOwner,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1698,7 +1697,7 @@ func NewJobLabelsMetricCollector() *metric.MetricCollector {
 func NewPodsWithReplicaSetOwnerMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.PodsWithReplicaSetOwnerID,
-		scrape.KubePodOwner,
+		metric.KubePodOwner,
 		[]string{
 			source.NamespaceLabel,
 			source.PodLabel,
@@ -1724,7 +1723,7 @@ func NewPodsWithReplicaSetOwnerMetricCollector() *metric.MetricCollector {
 func NewReplicaSetsWithoutOwnersMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.ReplicaSetsWithoutOwnersID,
-		scrape.KubeReplicasetOwner,
+		metric.KubeReplicasetOwner,
 		[]string{
 			source.NamespaceLabel,
 			source.ReplicaSetLabel,
@@ -1748,7 +1747,7 @@ func NewReplicaSetsWithoutOwnersMetricCollector() *metric.MetricCollector {
 func NewReplicaSetsWithRolloutMetricCollector() *metric.MetricCollector {
 	return metric.NewMetricCollector(
 		metric.ReplicaSetsWithRolloutID,
-		scrape.KubeReplicasetOwner,
+		metric.KubeReplicasetOwner,
 		[]string{
 			source.NamespaceLabel,
 			source.ReplicaSetLabel,

+ 20 - 2
modules/collector-source/pkg/collector/datasource.go

@@ -1,6 +1,7 @@
 package collector
 
 import (
+	"context"
 	"time"
 
 	"github.com/julienschmidt/httprouter"
@@ -21,6 +22,7 @@ type collectorDataSource struct {
 	clusterMap     clusters.ClusterMap
 	clusterInfo    clusters.ClusterInfoProvider
 	config         CollectorConfig
+	diagnosticsModule    *metric.DiagnosticsModule
 }
 
 func NewDefaultCollectorDataSource(
@@ -67,7 +69,7 @@ func NewCollectorDataSource(
 			config.ClusterID,
 			store,
 			resolutions,
-			repo,
+			updater,
 		)
 		if err != nil {
 			log.Errorf("failed to initialize the walinator: %s", err.Error())
@@ -77,6 +79,8 @@ func NewCollectorDataSource(
 		}
 	}
 
+	diagnosticsModule := metric.NewDiagnosticsModule(updater)
+	updater = diagnosticsModule
 	scrapeController := scrape.NewScrapeController(
 		config.ScrapeInterval,
 		config.NetworkPort,
@@ -98,6 +102,7 @@ func NewCollectorDataSource(
 		metricsQuerier: metricQuerier,
 		clusterInfo:    clusterInfo,
 		clusterMap:     clusterMap,
+		diagnosticsModule:    diagnosticsModule,
 	}
 }
 
@@ -106,7 +111,20 @@ func (c *collectorDataSource) RegisterEndPoints(router *httprouter.Router) {
 }
 
 func (c *collectorDataSource) RegisterDiagnostics(diagService diagnostics.DiagnosticService) {
-	return
+	const CollectorDiagnosticCategory = "collector"
+	diagnosticDefinitions := c.diagnosticsModule.DiagnosticsDefinitions()
+	for _, dd := range diagnosticDefinitions {
+		err := diagService.Register(dd.ID, dd.Description, CollectorDiagnosticCategory, func(ctx context.Context) (map[string]any, error) {
+			details, err := c.diagnosticsModule.DiagnosticsDetails(dd.ID)
+			if err != nil {
+				return nil, err
+			}
+			return details, nil
+		})
+		if err != nil {
+			log.Warnf("Failed to register collector diagnostic %s: %s", dd.ID, err.Error())
+		}
+	}
 }
 
 func (c *collectorDataSource) Metrics() source.MetricsQuerier {

+ 39 - 40
modules/collector-source/pkg/collector/metricsquerier_test.go

@@ -10,7 +10,6 @@ import (
 	"github.com/opencost/opencost/core/pkg/source"
 	"github.com/opencost/opencost/core/pkg/util"
 	"github.com/opencost/opencost/modules/collector-source/pkg/metric"
-	"github.com/opencost/opencost/modules/collector-source/pkg/scrape"
 )
 
 var Start1Str = "2025-01-01T00:00:00Z"
@@ -124,55 +123,55 @@ func GetMockCollectorProvider() StoreProvider {
 		source.ServiceLabel:    "service2",
 	}
 
-	collector.Update(scrape.NodeTotalHourlyCost, node1Info, 0, start, nil)
-	collector.Update(scrape.NodeTotalHourlyCost, node1Info, 0, end, nil)
+	collector.Update(metric.NodeTotalHourlyCost, node1Info, 0, start, nil)
+	collector.Update(metric.NodeTotalHourlyCost, node1Info, 0, end, nil)
 
-	collector.Update(scrape.NodeFSCapacityBytes, localStorage1Info, 2*GiB, start, nil)
-	collector.Update(scrape.ContainerFSUsageBytes, localStorage1Info, 1*GiB, start, nil)
-	collector.Update(scrape.ContainerFSUsageBytes, localStorage1Info, 1*GiB, end, nil)
+	collector.Update(metric.NodeFSCapacityBytes, localStorage1Info, 2*GiB, start, nil)
+	collector.Update(metric.ContainerFSUsageBytes, localStorage1Info, 1*GiB, start, nil)
+	collector.Update(metric.ContainerFSUsageBytes, localStorage1Info, 1*GiB, end, nil)
 
-	collector.Update(scrape.KubeNodeStatusCapacityMemoryBytes, node1Info, 4*GiB, start, nil)
-	collector.Update(scrape.ContainerMemoryWorkingSetBytes, container1Info, 1*GiB, start, nil)
-	collector.Update(scrape.ContainerMemoryWorkingSetBytes, container2Info, 2*GiB, start, nil)
+	collector.Update(metric.KubeNodeStatusCapacityMemoryBytes, node1Info, 4*GiB, start, nil)
+	collector.Update(metric.ContainerMemoryWorkingSetBytes, container1Info, 1*GiB, start, nil)
+	collector.Update(metric.ContainerMemoryWorkingSetBytes, container2Info, 2*GiB, start, nil)
 
-	collector.Update(scrape.ContainerCPUUsageSecondsTotal, container1Info, 0, start, nil)
-	collector.Update(scrape.ContainerCPUUsageSecondsTotal, container1Info, 60*60*4, time1, nil)
-	collector.Update(scrape.ContainerCPUUsageSecondsTotal, container1Info, 60*60*10, end, nil)
+	collector.Update(metric.ContainerCPUUsageSecondsTotal, container1Info, 0, start, nil)
+	collector.Update(metric.ContainerCPUUsageSecondsTotal, container1Info, 60*60*4, time1, nil)
+	collector.Update(metric.ContainerCPUUsageSecondsTotal, container1Info, 60*60*10, end, nil)
 
-	collector.Update(scrape.KubecostClusterManagementCost, cluster1Info, 0.1, start, nil)
-	collector.Update(scrape.KubecostClusterManagementCost, cluster1Info, 0.1, end, nil)
+	collector.Update(metric.KubecostClusterManagementCost, cluster1Info, 0.1, start, nil)
+	collector.Update(metric.KubecostClusterManagementCost, cluster1Info, 0.1, end, nil)
 
-	collector.Update(scrape.DCGMFIDEVDECUTIL, gpu1Info, 0, start, nil)
-	collector.Update(scrape.DCGMFIPROFGRENGINEACTIVE, gpu1Info, 0, start, nil)
-	collector.Update(scrape.DCGMFIPROFGRENGINEACTIVE, gpu1Info, 1, end, nil)
+	collector.Update(metric.DCGMFIDEVDECUTIL, gpu1Info, 0, start, nil)
+	collector.Update(metric.DCGMFIPROFGRENGINEACTIVE, gpu1Info, 0, start, nil)
+	collector.Update(metric.DCGMFIPROFGRENGINEACTIVE, gpu1Info, 1, end, nil)
 
-	collector.Update(scrape.KubecostNetworkZoneEgressCost, nil, 1, start, nil)
-	collector.Update(scrape.KubecostNetworkRegionEgressCost, nil, 2, start, nil)
-	collector.Update(scrape.KubecostNetworkInternetEgressCost, nil, 3, start, nil)
+	collector.Update(metric.KubecostNetworkZoneEgressCost, nil, 1, start, nil)
+	collector.Update(metric.KubecostNetworkRegionEgressCost, nil, 2, start, nil)
+	collector.Update(metric.KubecostNetworkInternetEgressCost, nil, 3, start, nil)
 
-	collector.Update(scrape.ContainerNetworkTransmitBytesTotal, pod1Info, 3*GiB, start, nil)
-	collector.Update(scrape.ContainerNetworkTransmitBytesTotal, pod1Info, 13*GiB, end, nil)
+	collector.Update(metric.ContainerNetworkTransmitBytesTotal, pod1Info, 3*GiB, start, nil)
+	collector.Update(metric.ContainerNetworkTransmitBytesTotal, pod1Info, 13*GiB, end, nil)
 
-	collector.Update(scrape.ContainerNetworkReceiveBytesTotal, pod1Info, 30*GiB, start, nil)
-	collector.Update(scrape.ContainerNetworkReceiveBytesTotal, pod1Info, 130*GiB, end, nil)
+	collector.Update(metric.ContainerNetworkReceiveBytesTotal, pod1Info, 30*GiB, start, nil)
+	collector.Update(metric.ContainerNetworkReceiveBytesTotal, pod1Info, 130*GiB, end, nil)
 
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkRegion1Info, 1*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkZone1Info, 0*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkInternet1Info, 1*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkInternet2Info, 1*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkRegion1Info, 2*GiB, end, nil)
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkZone1Info, 2*GiB, end, nil)
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkInternet1Info, 4*GiB, end, nil)
-	collector.Update(scrape.KubecostPodNetworkEgressBytesTotal, networkInternet2Info, 5*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkRegion1Info, 1*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkZone1Info, 0*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkInternet1Info, 1*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkInternet2Info, 1*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkRegion1Info, 2*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkZone1Info, 2*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkInternet1Info, 4*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkEgressBytesTotal, networkInternet2Info, 5*GiB, end, nil)
 
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkRegion1Info, 10*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkZone1Info, 0*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkInternet1Info, 10*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkInternet2Info, 10*GiB, start, nil)
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkRegion1Info, 20*GiB, end, nil)
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkZone1Info, 20*GiB, end, nil)
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkInternet1Info, 40*GiB, end, nil)
-	collector.Update(scrape.KubecostPodNetworkIngressBytesTotal, networkInternet2Info, 50*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkRegion1Info, 10*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkZone1Info, 0*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkInternet1Info, 10*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkInternet2Info, 10*GiB, start, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkRegion1Info, 20*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkZone1Info, 20*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkInternet1Info, 40*GiB, end, nil)
+	collector.Update(metric.KubecostPodNetworkIngressBytesTotal, networkInternet2Info, 50*GiB, end, nil)
 
 	return &MockStoreProvider{
 		metricsCollector: collector,

+ 1 - 1
modules/collector-source/pkg/metric/collector.go

@@ -148,4 +148,4 @@ func (mi *MetricCollector) Get() []*aggregator.MetricResult {
 
 func (mi *MetricCollector) Labels() []string {
 	return mi.labels
-}
+}

+ 142 - 0
modules/collector-source/pkg/metric/diagnostics.go

@@ -0,0 +1,142 @@
+package metric
+
+import (
+	"fmt"
+	"maps"
+	"sync"
+)
+
+// Collector Metric Diagnostic IDs
+const (
+	// KubecostDiagnosticMetricID is the identifier for the metric used to determine if Kubecost metrics are being scraped.
+	KubecostDiagnosticMetricID = "kubecostMetric"
+
+	// NodesDiagnosticMetricID is the identifier for the query used to determine if the node CPU cores capacity is being scraped
+	NodesDiagnosticMetricID = "nodesCPUMetrics"
+)
+
+// diagnostic definitions mapping holds all of the diagnostic definitions that can be used for collector metrics diagnostics
+var diagnosticDefinitions map[string]*diagnosticDefinition = map[string]*diagnosticDefinition{
+	NodesDiagnosticMetricID: {
+		ID:          NodesDiagnosticMetricID,
+		MetricName:  KubeNodeStatusCapacityCPUCores,
+		Label:       "Node CPU cores capacity is being scraped",
+		Description: "Determine if the node CPU cores capacity is being scraped",
+	},
+
+	KubecostDiagnosticMetricID: {
+		ID:          KubecostDiagnosticMetricID,
+		MetricName:  NodeTotalHourlyCost,
+		Label:       "Kubecost metrics for a node are being scraped",
+		Description: "Determine if kubecost metrics for a node are being scraped",
+	},
+}
+
+// diagnosticsResults stores the current state of diagnostic results
+var diagnosticsResults map[string]*diagnosticsResult = make(map[string]*diagnosticsResult)
+
+type diagnosticDefinition struct {
+	ID          string
+	MetricName  string
+	Label       string
+	Description string
+	DocLink     string
+}
+
+type diagnosticsResult struct {
+	Result map[string]any
+	Passed bool
+}
+
+type DiagnosticsModule struct {
+	lock    sync.RWMutex
+	updater Updater
+}
+
+func NewDiagnosticsModule(updater Updater) *DiagnosticsModule {
+	// Initialize diagnostics results to false to represent that no data has been collected yet
+	for id := range diagnosticDefinitions {
+		diagnosticsResults[id] = &diagnosticsResult{
+			Result: make(map[string]any),
+			Passed: false,
+		}
+	}
+
+	return &DiagnosticsModule{
+		updater: updater,
+	}
+}
+
+func (d *DiagnosticsModule) Update(updateSet *UpdateSet) {
+	if updateSet == nil {
+		return
+	}
+
+	// Create a deep copy for the async update to avoid race condition
+	updateSetCopy := &UpdateSet{
+		Timestamp: updateSet.Timestamp,
+		Updates:   make([]Update, len(updateSet.Updates)),
+	}
+	copy(updateSetCopy.Updates, updateSet.Updates)
+
+	// This is done so that the update func is marked complete when both the updater and diagnostics are done
+	// Otherwise we might face a race condition when calling the diagnostics details func before the diagnostics are done
+	var wg sync.WaitGroup
+	wg.Add(2) // 1 for updater, 1 for diagnostics
+
+	go func() {
+		defer wg.Done()
+		d.lock.Lock()
+		defer d.lock.Unlock()
+
+		timestamp := updateSet.Timestamp.String()
+		for id, dd := range diagnosticDefinitions {
+			for _, update := range updateSet.Updates {
+				if update.Name == dd.MetricName {
+					if len(diagnosticsResults[id].Result) == 0 {
+						// For the first UpdateSet received for that metric, we default to true. If we later miss the metric for a timestamp, it will be set to false.
+						diagnosticsResults[id].Passed = true
+					}
+					diagnosticsResults[id].Result[timestamp] = update.Value
+				}
+			}
+			if diagnosticsResults[id].Result[timestamp] == nil {
+				diagnosticsResults[id].Passed = false
+			}
+		}
+	}()
+
+	// We are still maintaining the order in which the updates to the repo are called
+	// as this function gets the new call only when both these go routines are done
+	go func() {
+		defer wg.Done()
+		d.updater.Update(updateSetCopy)
+	}()
+
+	wg.Wait()
+}
+
+func (d *DiagnosticsModule) DiagnosticsDefinitions() map[string]*diagnosticDefinition {
+	return diagnosticDefinitions
+}
+
+func (d *DiagnosticsModule) DiagnosticsDetails(diagnosticsId string) (map[string]any, error) {
+	d.lock.RLock()
+	defer d.lock.RUnlock()
+
+	if _, exists := diagnosticDefinitions[diagnosticsId]; !exists {
+		return nil, fmt.Errorf("diagnostic ID: %s not found", diagnosticsId)
+	}
+
+	details := map[string]any{
+		"query":   diagnosticDefinitions[diagnosticsId].MetricName,
+		"label":   diagnosticDefinitions[diagnosticsId].Label,
+		"docLink": diagnosticDefinitions[diagnosticsId].DocLink,
+		"result":  maps.Clone(diagnosticsResults[diagnosticsId].Result),
+		"passed":  diagnosticsResults[diagnosticsId].Passed,
+	}
+	// reset the result and passed for the next run
+	diagnosticsResults[diagnosticsId].Result = make(map[string]any)
+	diagnosticsResults[diagnosticsId].Passed = false
+	return details, nil
+}

+ 194 - 0
modules/collector-source/pkg/metric/diagnostics_test.go

@@ -0,0 +1,194 @@
+package metric
+
+import (
+	"testing"
+	"time"
+)
+
+// MockUpdater implements the Updater interface for testing
+type MockUpdater struct {
+}
+
+func (m *MockUpdater) Update(updateSet *UpdateSet) {
+}
+
+// Test Update func in DiagnosticsModule and check if diagnostics pass
+func TestDiagnosticsModule_Update(t *testing.T) {
+	mockUpdater := &MockUpdater{}
+	module := NewDiagnosticsModule(mockUpdater)
+
+	// Test with valid update set containing node metrics
+	timestamp := time.Now()
+	updateSet := &UpdateSet{
+		Timestamp: timestamp,
+		Updates: []Update{
+			{
+				Name:  KubeNodeStatusCapacityCPUCores,
+				Value: 4.0,
+			},
+			{
+				Name:  NodeTotalHourlyCost,
+				Value: 0.50,
+			},
+		},
+	}
+
+	module.Update(updateSet)
+
+	// Check both diagnostics
+	nodeDetails, err := module.DiagnosticsDetails(NodesDiagnosticMetricID)
+	if err != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+	if nodeDetails["passed"] != true {
+		t.Error("Expected node diagnostic to pass")
+	}
+
+	kubecostDetails, err := module.DiagnosticsDetails(KubecostDiagnosticMetricID)
+	if err != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+	if kubecostDetails["passed"] != true {
+		t.Error("Expected kubecost diagnostic to pass")
+	}
+}
+
+// Test Update func in DiagnosticsModule with missing metrics and test if diagnostics fail
+func TestDiagnosticsModule_UpdateWithMissingMetrics(t *testing.T) {
+	mockUpdater := &MockUpdater{}
+	module := NewDiagnosticsModule(mockUpdater)
+
+	timestamp := time.Now()
+	updateSet := &UpdateSet{
+		Timestamp: timestamp,
+		Updates: []Update{
+			{
+				Name:  "some_other_metric",
+				Value: 1.0,
+			},
+		},
+	}
+
+	module.Update(updateSet)
+
+	// Check that diagnostics fail when their metrics are missing
+	nodeDetails, err := module.DiagnosticsDetails(NodesDiagnosticMetricID)
+	if err != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+	if nodeDetails["passed"] != false {
+		t.Error("Expected node diagnostic to fail when metric is missing")
+	}
+
+	kubecostDetails, err := module.DiagnosticsDetails(KubecostDiagnosticMetricID)
+	if err != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+	if kubecostDetails["passed"] != false {
+		t.Error("Expected kubecost diagnostic to fail when metric is missing")
+	}
+}
+
+// Test DiagnosticsDetails func in DiagnosticsModule with invalid and valid diagnostic IDs
+func TestDiagnosticsModule_DiagnosticsDetails(t *testing.T) {
+	mockUpdater := &MockUpdater{}
+	module := NewDiagnosticsModule(mockUpdater)
+
+	// Test with invalid diagnostic ID
+	_, err := module.DiagnosticsDetails("invalid_id")
+	if err.Error() != "diagnostic ID: invalid_id not found" {
+		t.Error("Expected error for invalid diagnostic ID")
+	}
+
+	// Test with valid diagnostic ID
+	details, err := module.DiagnosticsDetails(NodesDiagnosticMetricID)
+	if err != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+	if details["error"] != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+
+	// Check required fields
+	requiredFields := []string{"query", "label", "result", "passed", "docLink"}
+	for _, field := range requiredFields {
+		if details[field] == nil {
+			t.Errorf("Expected field %s to be present", field)
+		}
+	}
+}
+
+// Test concurrent access(race condition) to DiagnosticsModule
+func TestDiagnosticsModule_ConcurrentAccess(t *testing.T) {
+	mockUpdater := &MockUpdater{}
+	module := NewDiagnosticsModule(mockUpdater)
+
+	// Test concurrent access to diagnostics
+	done := make(chan bool, 2)
+
+	go func() {
+		for i := 0; i < 100; i++ {
+			module.DiagnosticsDefinitions()
+		}
+		done <- true
+	}()
+
+	go func() {
+		for i := 0; i < 100; i++ {
+			timestamp := time.Now()
+			updateSet := &UpdateSet{
+				Timestamp: timestamp,
+				Updates: []Update{
+					{
+						Name:  KubeNodeStatusCapacityCPUCores,
+						Value: float64(i),
+					},
+				},
+			}
+			module.Update(updateSet)
+		}
+		done <- true
+	}()
+
+	<-done
+	<-done
+	// If we get here without a race condition, the test passes
+}
+
+// Test reset of diagnostics after details are retrieved
+func TestDiagnosticsModule_ResetAfterDetails(t *testing.T) {
+	mockUpdater := &MockUpdater{}
+	module := NewDiagnosticsModule(mockUpdater)
+
+	// Add some data
+	timestamp := time.Now()
+	updateSet := &UpdateSet{
+		Timestamp: timestamp,
+		Updates: []Update{
+			{
+				Name:  KubeNodeStatusCapacityCPUCores,
+				Value: 4.0,
+			},
+		},
+	}
+
+	module.Update(updateSet)
+
+	// Get details (this should reset the diagnostic)
+	details, err := module.DiagnosticsDetails(NodesDiagnosticMetricID)
+	if err != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+	if details["passed"] != true {
+		t.Error("Expected diagnostic to pass before reset")
+	}
+
+	// Get details again (should be reset)
+	details2, err := module.DiagnosticsDetails(NodesDiagnosticMetricID)
+	if err != nil {
+		t.Error("Expected no error for valid diagnostic ID")
+	}
+	if details2["passed"] != false {
+		t.Error("Expected diagnostic to be reset after first details call")
+	}
+}

+ 61 - 0
modules/collector-source/pkg/metric/metrics.go

@@ -0,0 +1,61 @@
+package metric
+
+const (
+	// Cluster Cache Metrics
+	KubeNodeStatusCapacityCPUCores                        = "kube_node_status_capacity_cpu_cores"
+	KubeNodeStatusCapacityMemoryBytes                     = "kube_node_status_capacity_memory_bytes"
+	KubeNodeStatusAllocatableCPUCores                     = "kube_node_status_allocatable_cpu_cores"
+	KubeNodeStatusAllocatableMemoryBytes                  = "kube_node_status_allocatable_memory_bytes"
+	KubeNodeLabels                                        = "kube_node_labels"
+	KubePodLabels                                         = "kube_pod_labels"
+	KubePodAnnotations                                    = "kube_pod_annotations"
+	KubePodOwner                                          = "kube_pod_owner"
+	KubePodContainerStatusRunning                         = "kube_pod_container_status_running"
+	KubePodContainerResourceRequests                      = "kube_pod_container_resource_requests"
+	KubePersistentVolumeClaimInfo                         = "kube_persistentvolumeclaim_info"
+	KubePersistentVolumeClaimResourceRequestsStorageBytes = "kube_persistentvolumeclaim_resource_requests_storage_bytes"
+	KubecostPVInfo                                        = "kubecost_pv_info"
+	KubePersistentVolumeCapacityBytes                     = "kube_persistentvolume_capacity_bytes"
+	DeploymentMatchLabels                                 = "deployment_match_labels"
+	KubeNamespaceLabels                                   = "kube_namespace_labels"
+	KubeNamespaceAnnotations                              = "kube_namespace_annotations"
+	ServiceSelectorLabels                                 = "service_selector_labels"
+	StatefulSetMatchLabels                                = "statefulSet_match_labels"
+	KubeReplicasetOwner                                   = "kube_replicaset_owner"
+
+	// DCGM Metrics
+	DCGMFIPROFGRENGINEACTIVE = "DCGM_FI_PROF_GR_ENGINE_ACTIVE"
+	DCGMFIDEVDECUTIL         = "DCGM_FI_DEV_DEC_UTIL"
+
+	// Network Metrics
+	KubecostPodNetworkEgressBytesTotal  = "kubecost_pod_network_egress_bytes_total"
+	KubecostPodNetworkIngressBytesTotal = "kubecost_pod_network_ingress_bytes_total"
+
+	// Opencost Metrics
+	KubecostClusterManagementCost     = "kubecost_cluster_management_cost"
+	KubecostNetworkZoneEgressCost     = "kubecost_network_zone_egress_cost"
+	KubecostNetworkRegionEgressCost   = "kubecost_network_region_egress_cost"
+	KubecostNetworkInternetEgressCost = "kubecost_network_internet_egress_cost"
+	PVHourlyCost                      = "pv_hourly_cost"
+	KubecostLoadBalancerCost          = "kubecost_load_balancer_cost"
+	NodeTotalHourlyCost               = "node_total_hourly_cost"
+	NodeCPUHourlyCost                 = "node_cpu_hourly_cost"
+	NodeRAMHourlyCost                 = "node_ram_hourly_cost"
+	NodeGPUHourlyCost                 = "node_gpu_hourly_cost"
+	NodeGPUCount                      = "node_gpu_count"
+	KubecostNodeIsSpot                = "kubecost_node_is_spot"
+	ContainerCPUAllocation            = "container_cpu_allocation"
+	ContainerMemoryAllocationBytes    = "container_memory_allocation_bytes"
+	ContainerGPUAllocation            = "container_gpu_allocation"
+	PodPVCAllocation                  = "pod_pvc_allocation"
+
+	// Stat Summary Metrics
+	NodeCPUSecondsTotal                = "node_cpu_seconds_total"
+	NodeFSCapacityBytes                = "node_fs_capacity_bytes" // replaces container_fs_limit_bytes
+	ContainerNetworkReceiveBytesTotal  = "container_network_receive_bytes_total"
+	ContainerNetworkTransmitBytesTotal = "container_network_transmit_bytes_total"
+	ContainerCPUUsageSecondsTotal      = "container_cpu_usage_seconds_total"
+	ContainerMemoryWorkingSetBytes     = "container_memory_working_set_bytes"
+	ContainerFSUsageBytes              = "container_fs_usage_bytes"
+	KubeletVolumeStatsUsedBytes        = "kubelet_volume_stats_used_bytes"
+)

+ 7 - 7
modules/collector-source/pkg/metric/walinator.go

@@ -32,14 +32,14 @@ type Walinator struct {
 	paths           pathing.StoragePathFormatter[time.Time]
 	exporter        exporter.EventExporter[UpdateSet]
 	limitResolution *util.Resolution
-	repo            *MetricRepository
+	updater         Updater
 }
 
 func NewWalinator(
 	clusterID string,
 	store storage.Storage,
 	resolutions []*util.Resolution,
-	repo *MetricRepository,
+	updater Updater,
 ) (*Walinator, error) {
 	var limitResolution *util.Resolution
 	for _, resolution := range resolutions {
@@ -63,7 +63,7 @@ func NewWalinator(
 		paths:           pathFormatter,
 		exporter:        exp,
 		limitResolution: limitResolution,
-		repo:            repo,
+		updater:         updater,
 	}, nil
 }
 
@@ -80,7 +80,7 @@ func (w *Walinator) Start() {
 	}()
 }
 
-// restore applies updates from wal files to restore the state of the repo
+// restore applies updates from wal files to restore the state of the previous updater(repo)
 func (w *Walinator) restore() {
 	fileInfos, err := w.getFileInfos()
 	if err != nil {
@@ -113,7 +113,7 @@ func (w *Walinator) restore() {
 	}
 
 	processFn := func(updateSet *UpdateSet) {
-		w.repo.Update(updateSet)
+		w.updater.Update(updateSet)
 	}
 	worker.ConcurrentOrderedProcessWith(worker.OptimalWorkerCount(), workerFn, fileInfos, processFn)
 }
@@ -147,7 +147,7 @@ func deserializeUpdateSet(ext string, b []byte) (*UpdateSet, error) {
 	return nil, fmt.Errorf("unrecognized extension: '%s'", ext)
 }
 
-// Update calls update on the repo and then exports the update to storage
+// Update calls update on the previous updater(repo) and then exports the update to storage
 func (w *Walinator) Update(
 	updateSet *UpdateSet,
 ) {
@@ -156,7 +156,7 @@ func (w *Walinator) Update(
 	}
 
 	// run update
-	w.repo.Update(updateSet)
+	w.updater.Update(updateSet)
 
 	err := w.exporter.Export(updateSet.Timestamp, updateSet)
 	if err != nil {

+ 1 - 1
modules/collector-source/pkg/metric/walinator_test.go

@@ -164,7 +164,7 @@ func TestWalinator_restore(t *testing.T) {
 	)
 
 	// replace the repo in the walinator
-	wal.repo = repo2
+	wal.updater = repo2
 
 	wal.restore()
 

+ 20 - 44
modules/collector-source/pkg/scrape/clustercache.go

@@ -17,30 +17,6 @@ import (
 	"k8s.io/apimachinery/pkg/util/validation"
 )
 
-// Cluster Cache Metrics
-const (
-	KubeNodeStatusCapacityCPUCores                        = "kube_node_status_capacity_cpu_cores"
-	KubeNodeStatusCapacityMemoryBytes                     = "kube_node_status_capacity_memory_bytes"
-	KubeNodeStatusAllocatableCPUCores                     = "kube_node_status_allocatable_cpu_cores"
-	KubeNodeStatusAllocatableMemoryBytes                  = "kube_node_status_allocatable_memory_bytes"
-	KubeNodeLabels                                        = "kube_node_labels"
-	KubePodLabels                                         = "kube_pod_labels"
-	KubePodAnnotations                                    = "kube_pod_annotations"
-	KubePodOwner                                          = "kube_pod_owner"
-	KubePodContainerStatusRunning                         = "kube_pod_container_status_running"
-	KubePodContainerResourceRequests                      = "kube_pod_container_resource_requests"
-	KubePersistentVolumeClaimInfo                         = "kube_persistentvolumeclaim_info"
-	KubePersistentVolumeClaimResourceRequestsStorageBytes = "kube_persistentvolumeclaim_resource_requests_storage_bytes"
-	KubecostPVInfo                                        = "kubecost_pv_info"
-	KubePersistentVolumeCapacityBytes                     = "kube_persistentvolume_capacity_bytes"
-	DeploymentMatchLabels                                 = "deployment_match_labels"
-	KubeNamespaceLabels                                   = "kube_namespace_labels"
-	KubeNamespaceAnnotations                              = "kube_namespace_annotations"
-	ServiceSelectorLabels                                 = "service_selector_labels"
-	StatefulSetMatchLabels                                = "statefulSet_match_labels"
-	KubeReplicasetOwner                                   = "kube_replicaset_owner"
-)
-
 type ClusterCacheScraper struct {
 	clusterCache clustercache.ClusterCache
 }
@@ -85,7 +61,7 @@ func (ccs *ClusterCacheScraper) scrapeNodes(nodes []*clustercache.Node) []metric
 			if quantity, ok := node.Status.Capacity[v1.ResourceCPU]; ok {
 				_, _, value := toResourceUnitValue(v1.ResourceCPU, quantity)
 				scrapeResults = append(scrapeResults, metric.Update{
-					Name:   KubeNodeStatusCapacityCPUCores,
+					Name:   metric.KubeNodeStatusCapacityCPUCores,
 					Labels: nodeInfo,
 					Value:  value,
 				})
@@ -94,7 +70,7 @@ func (ccs *ClusterCacheScraper) scrapeNodes(nodes []*clustercache.Node) []metric
 			if quantity, ok := node.Status.Capacity[v1.ResourceMemory]; ok {
 				_, _, value := toResourceUnitValue(v1.ResourceMemory, quantity)
 				scrapeResults = append(scrapeResults, metric.Update{
-					Name:   KubeNodeStatusCapacityMemoryBytes,
+					Name:   metric.KubeNodeStatusCapacityMemoryBytes,
 					Labels: nodeInfo,
 					Value:  value,
 				})
@@ -106,7 +82,7 @@ func (ccs *ClusterCacheScraper) scrapeNodes(nodes []*clustercache.Node) []metric
 			if quantity, ok := node.Status.Allocatable[v1.ResourceCPU]; ok {
 				_, _, value := toResourceUnitValue(v1.ResourceCPU, quantity)
 				scrapeResults = append(scrapeResults, metric.Update{
-					Name:   KubeNodeStatusAllocatableCPUCores,
+					Name:   metric.KubeNodeStatusAllocatableCPUCores,
 					Labels: nodeInfo,
 					Value:  value,
 				})
@@ -115,7 +91,7 @@ func (ccs *ClusterCacheScraper) scrapeNodes(nodes []*clustercache.Node) []metric
 			if quantity, ok := node.Status.Allocatable[v1.ResourceMemory]; ok {
 				_, _, value := toResourceUnitValue(v1.ResourceMemory, quantity)
 				scrapeResults = append(scrapeResults, metric.Update{
-					Name:   KubeNodeStatusAllocatableMemoryBytes,
+					Name:   metric.KubeNodeStatusAllocatableMemoryBytes,
 					Labels: nodeInfo,
 					Value:  value,
 				})
@@ -127,7 +103,7 @@ func (ccs *ClusterCacheScraper) scrapeNodes(nodes []*clustercache.Node) []metric
 		nodeLabels := util.ToMap(labelNames, labelValues)
 
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           KubeNodeLabels,
+			Name:           metric.KubeNodeLabels,
 			Labels:         nodeInfo,
 			Value:          0,
 			AdditionalInfo: nodeLabels,
@@ -155,7 +131,7 @@ func (ccs *ClusterCacheScraper) scrapeDeployments(deployments []*clustercache.De
 		deploymentLabels := util.ToMap(labelNames, labelValues)
 
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           DeploymentMatchLabels,
+			Name:           metric.DeploymentMatchLabels,
 			Labels:         deploymentInfo,
 			Value:          0,
 			AdditionalInfo: deploymentLabels,
@@ -180,7 +156,7 @@ func (ccs *ClusterCacheScraper) scrapeNamespaces(namespaces []*clustercache.Name
 		labelNames, labelValues := promutil.KubeLabelsToLabels(namespace.Labels)
 		namespaceLabels := util.ToMap(labelNames, labelValues)
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           KubeNamespaceLabels,
+			Name:           metric.KubeNamespaceLabels,
 			Labels:         namespaceInfo,
 			Value:          0,
 			AdditionalInfo: namespaceLabels,
@@ -190,7 +166,7 @@ func (ccs *ClusterCacheScraper) scrapeNamespaces(namespaces []*clustercache.Name
 		annotationNames, annotationValues := promutil.KubeAnnotationsToLabels(namespace.Annotations)
 		namespaceAnnotations := util.ToMap(annotationNames, annotationValues)
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           KubeNamespaceAnnotations,
+			Name:           metric.KubeNamespaceAnnotations,
 			Labels:         namespaceInfo,
 			Value:          0,
 			AdditionalInfo: namespaceAnnotations,
@@ -219,7 +195,7 @@ func (ccs *ClusterCacheScraper) scrapePods(pods []*clustercache.Pod) []metric.Up
 		labelNames, labelValues := promutil.KubeLabelsToLabels(pod.Labels)
 		podLabels := util.ToMap(labelNames, labelValues)
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           KubePodLabels,
+			Name:           metric.KubePodLabels,
 			Labels:         podInfo,
 			Value:          0,
 			AdditionalInfo: podLabels,
@@ -229,7 +205,7 @@ func (ccs *ClusterCacheScraper) scrapePods(pods []*clustercache.Pod) []metric.Up
 		annotationNames, annotationValues := promutil.KubeAnnotationsToLabels(pod.Annotations)
 		podAnnotations := util.ToMap(annotationNames, annotationValues)
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           KubePodAnnotations,
+			Name:           metric.KubePodAnnotations,
 			Labels:         podInfo,
 			Value:          0,
 			AdditionalInfo: podAnnotations,
@@ -241,7 +217,7 @@ func (ccs *ClusterCacheScraper) scrapePods(pods []*clustercache.Pod) []metric.Up
 			ownerInfo[source.OwnerKindLabel] = owner.Kind
 			ownerInfo[source.OwnerNameLabel] = owner.Name
 			scrapeResults = append(scrapeResults, metric.Update{
-				Name:   KubePodOwner,
+				Name:   metric.KubePodOwner,
 				Labels: ownerInfo,
 				Value:  0,
 			})
@@ -253,7 +229,7 @@ func (ccs *ClusterCacheScraper) scrapePods(pods []*clustercache.Pod) []metric.Up
 				containerInfo := maps.Clone(podInfo)
 				containerInfo[source.ContainerLabel] = status.Name
 				scrapeResults = append(scrapeResults, metric.Update{
-					Name:   KubePodContainerStatusRunning,
+					Name:   metric.KubePodContainerStatusRunning,
 					Labels: containerInfo,
 					Value:  0,
 				})
@@ -282,7 +258,7 @@ func (ccs *ClusterCacheScraper) scrapePods(pods []*clustercache.Pod) []metric.Up
 					resourceRequestInfo[source.ResourceLabel] = resource
 					resourceRequestInfo[source.UnitLabel] = unit
 					scrapeResults = append(scrapeResults, metric.Update{
-						Name:   KubePodContainerResourceRequests,
+						Name:   metric.KubePodContainerResourceRequests,
 						Labels: resourceRequestInfo,
 						Value:  value,
 					})
@@ -309,14 +285,14 @@ func (ccs *ClusterCacheScraper) scrapePVCs(pvcs []*clustercache.PersistentVolume
 		}
 
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:   KubePersistentVolumeClaimInfo,
+			Name:   metric.KubePersistentVolumeClaimInfo,
 			Labels: pvcInfo,
 			Value:  0,
 		})
 
 		if storage, ok := pvc.Spec.Resources.Requests[v1.ResourceStorage]; ok {
 			scrapeResults = append(scrapeResults, metric.Update{
-				Name:   KubePersistentVolumeClaimResourceRequestsStorageBytes,
+				Name:   metric.KubePersistentVolumeClaimResourceRequestsStorageBytes,
 				Labels: pvcInfo,
 				Value:  float64(storage.Value()),
 			})
@@ -345,14 +321,14 @@ func (ccs *ClusterCacheScraper) scrapePVs(pvs []*clustercache.PersistentVolume)
 		}
 
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:   KubecostPVInfo,
+			Name:   metric.KubecostPVInfo,
 			Labels: pvInfo,
 			Value:  0,
 		})
 
 		if storage, ok := pv.Spec.Capacity[v1.ResourceStorage]; ok {
 			scrapeResults = append(scrapeResults, metric.Update{
-				Name:   KubePersistentVolumeCapacityBytes,
+				Name:   metric.KubePersistentVolumeCapacityBytes,
 				Labels: pvInfo,
 				Value:  float64(storage.Value()),
 			})
@@ -378,7 +354,7 @@ func (ccs *ClusterCacheScraper) scrapeServices(services []*clustercache.Service)
 		labelNames, labelValues := promutil.KubeLabelsToLabels(service.SpecSelector)
 		serviceLabels := util.ToMap(labelNames, labelValues)
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           ServiceSelectorLabels,
+			Name:           metric.ServiceSelectorLabels,
 			Labels:         serviceInfo,
 			Value:          0,
 			AdditionalInfo: serviceLabels,
@@ -405,7 +381,7 @@ func (ccs *ClusterCacheScraper) scrapeStatefulSets(statefulSets []*clustercache.
 		labelNames, labelValues := promutil.KubeLabelsToLabels(statefulSet.SpecSelector.MatchLabels)
 		statefulSetLabels := util.ToMap(labelNames, labelValues)
 		scrapeResults = append(scrapeResults, metric.Update{
-			Name:           StatefulSetMatchLabels,
+			Name:           metric.StatefulSetMatchLabels,
 			Labels:         statefulSetInfo,
 			Value:          0,
 			AdditionalInfo: statefulSetLabels,
@@ -432,7 +408,7 @@ func (ccs *ClusterCacheScraper) scrapeReplicaSets(replicaSets []*clustercache.Re
 			ownerInfo[source.OwnerKindLabel] = owner.Kind
 			ownerInfo[source.OwnerNameLabel] = owner.Name
 			scrapeResults = append(scrapeResults, metric.Update{
-				Name:   KubeReplicasetOwner,
+				Name:   metric.KubeReplicasetOwner,
 				Labels: ownerInfo,
 				Value:  0,
 			})

+ 21 - 21
modules/collector-source/pkg/scrape/clustercache_test.go

@@ -58,7 +58,7 @@ func Test_kubernetesScraper_scrapeNodes(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: KubeNodeStatusCapacityCPUCores,
+					Name: metric.KubeNodeStatusCapacityCPUCores,
 					Labels: map[string]string{
 						source.NodeLabel:       "node1",
 						source.ProviderIDLabel: "i-1",
@@ -67,7 +67,7 @@ func Test_kubernetesScraper_scrapeNodes(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubeNodeStatusCapacityMemoryBytes,
+					Name: metric.KubeNodeStatusCapacityMemoryBytes,
 					Labels: map[string]string{
 						source.NodeLabel:       "node1",
 						source.ProviderIDLabel: "i-1",
@@ -76,7 +76,7 @@ func Test_kubernetesScraper_scrapeNodes(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubeNodeStatusAllocatableCPUCores,
+					Name: metric.KubeNodeStatusAllocatableCPUCores,
 					Labels: map[string]string{
 						source.NodeLabel:       "node1",
 						source.ProviderIDLabel: "i-1",
@@ -85,7 +85,7 @@ func Test_kubernetesScraper_scrapeNodes(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubeNodeStatusAllocatableMemoryBytes,
+					Name: metric.KubeNodeStatusAllocatableMemoryBytes,
 					Labels: map[string]string{
 						source.NodeLabel:       "node1",
 						source.ProviderIDLabel: "i-1",
@@ -94,7 +94,7 @@ func Test_kubernetesScraper_scrapeNodes(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubeNodeLabels,
+					Name: metric.KubeNodeLabels,
 					Labels: map[string]string{
 						source.NodeLabel:       "node1",
 						source.ProviderIDLabel: "i-1",
@@ -164,7 +164,7 @@ func Test_kubernetesScraper_scrapeDeployments(t *testing.T) {
 			expected: []metric.Update{
 
 				{
-					Name: DeploymentMatchLabels,
+					Name: metric.DeploymentMatchLabels,
 					Labels: map[string]string{
 						source.DeploymentLabel: "deployment1",
 						source.NamespaceLabel:  "namespace1",
@@ -236,7 +236,7 @@ func Test_kubernetesScraper_scrapeNamespaces(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: KubeNamespaceLabels,
+					Name: metric.KubeNamespaceLabels,
 					Labels: map[string]string{
 						source.NamespaceLabel: "namespace1",
 					},
@@ -247,7 +247,7 @@ func Test_kubernetesScraper_scrapeNamespaces(t *testing.T) {
 					},
 				},
 				{
-					Name: KubeNamespaceAnnotations,
+					Name: metric.KubeNamespaceAnnotations,
 					Labels: map[string]string{
 						source.NamespaceLabel: "namespace1",
 					},
@@ -351,7 +351,7 @@ func Test_kubernetesScraper_scrapePods(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: KubePodLabels,
+					Name: metric.KubePodLabels,
 					Labels: map[string]string{
 						source.PodLabel:       "pod1",
 						source.NamespaceLabel: "namespace1",
@@ -366,7 +366,7 @@ func Test_kubernetesScraper_scrapePods(t *testing.T) {
 					},
 				},
 				{
-					Name: KubePodAnnotations,
+					Name: metric.KubePodAnnotations,
 					Labels: map[string]string{
 						source.PodLabel:       "pod1",
 						source.NamespaceLabel: "namespace1",
@@ -381,7 +381,7 @@ func Test_kubernetesScraper_scrapePods(t *testing.T) {
 					},
 				},
 				{
-					Name: KubePodOwner,
+					Name: metric.KubePodOwner,
 					Labels: map[string]string{
 						source.PodLabel:       "pod1",
 						source.NamespaceLabel: "namespace1",
@@ -395,7 +395,7 @@ func Test_kubernetesScraper_scrapePods(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubePodContainerStatusRunning,
+					Name: metric.KubePodContainerStatusRunning,
 					Labels: map[string]string{
 						source.PodLabel:       "pod1",
 						source.NamespaceLabel: "namespace1",
@@ -408,7 +408,7 @@ func Test_kubernetesScraper_scrapePods(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubePodContainerResourceRequests,
+					Name: metric.KubePodContainerResourceRequests,
 					Labels: map[string]string{
 						source.PodLabel:       "pod1",
 						source.NamespaceLabel: "namespace1",
@@ -423,7 +423,7 @@ func Test_kubernetesScraper_scrapePods(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubePodContainerResourceRequests,
+					Name: metric.KubePodContainerResourceRequests,
 					Labels: map[string]string{
 						source.PodLabel:       "pod1",
 						source.NamespaceLabel: "namespace1",
@@ -500,7 +500,7 @@ func Test_kubernetesScraper_scrapePVCs(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: KubePersistentVolumeClaimInfo,
+					Name: metric.KubePersistentVolumeClaimInfo,
 					Labels: map[string]string{
 						source.PVCLabel:          "pvc1",
 						source.NamespaceLabel:    "namespace1",
@@ -511,7 +511,7 @@ func Test_kubernetesScraper_scrapePVCs(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubePersistentVolumeClaimResourceRequestsStorageBytes,
+					Name: metric.KubePersistentVolumeClaimResourceRequestsStorageBytes,
 					Labels: map[string]string{
 						source.PVCLabel:          "pvc1",
 						source.NamespaceLabel:    "namespace1",
@@ -585,7 +585,7 @@ func Test_kubernetesScraper_scrapePVs(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: KubecostPVInfo,
+					Name: metric.KubecostPVInfo,
 					Labels: map[string]string{
 						source.PVLabel:           "pv1",
 						source.ProviderIDLabel:   "vol-1",
@@ -595,7 +595,7 @@ func Test_kubernetesScraper_scrapePVs(t *testing.T) {
 					AdditionalInfo: nil,
 				},
 				{
-					Name: KubePersistentVolumeCapacityBytes,
+					Name: metric.KubePersistentVolumeCapacityBytes,
 					Labels: map[string]string{
 						source.PVLabel:           "pv1",
 						source.ProviderIDLabel:   "vol-1",
@@ -662,7 +662,7 @@ func Test_kubernetesScraper_scrapeServices(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: ServiceSelectorLabels,
+					Name: metric.ServiceSelectorLabels,
 					Labels: map[string]string{
 						"service":             "service1",
 						source.NamespaceLabel: "namespace1",
@@ -733,7 +733,7 @@ func Test_kubernetesScraper_scrapeStatefulSets(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: StatefulSetMatchLabels,
+					Name: metric.StatefulSetMatchLabels,
 					Labels: map[string]string{
 						source.StatefulSetLabel: "statefulSet1",
 						source.NamespaceLabel:   "namespace1",
@@ -804,7 +804,7 @@ func Test_kubernetesScraper_scrapeReplicaSets(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: KubeReplicasetOwner,
+					Name: metric.KubeReplicasetOwner,
 					Labels: map[string]string{
 						"replicaset":          "replicaSet1",
 						source.NamespaceLabel: "namespace1",

+ 3 - 8
modules/collector-source/pkg/scrape/dcgm.go

@@ -6,17 +6,12 @@ import (
 
 	"github.com/opencost/opencost/core/pkg/clustercache"
 	"github.com/opencost/opencost/core/pkg/log"
+	"github.com/opencost/opencost/modules/collector-source/pkg/metric"
 	"github.com/opencost/opencost/modules/collector-source/pkg/scrape/target"
 )
 
 var dcgmRegex = regexp.MustCompile("(?i)(.*dcgm-exporter.*)")
 
-// DCGM metrics
-const (
-	DCGMFIPROFGRENGINEACTIVE = "DCGM_FI_PROF_GR_ENGINE_ACTIVE"
-	DCGMFIDEVDECUTIL         = "DCGM_FI_DEV_DEC_UTIL"
-)
-
 func newDCGMScrapper(clusterCache clustercache.ClusterCache) Scraper {
 	tp := newDCGMTargetProvider(clusterCache)
 	return newDCGMTargetScraper(tp)
@@ -26,8 +21,8 @@ func newDCGMTargetScraper(provider target.TargetProvider) *TargetScraper {
 	return newTargetScrapper(
 		provider,
 		[]string{
-			DCGMFIPROFGRENGINEACTIVE,
-			DCGMFIDEVDECUTIL,
+			metric.DCGMFIPROFGRENGINEACTIVE,
+			metric.DCGMFIDEVDECUTIL,
 		},
 		true)
 }

+ 3 - 8
modules/collector-source/pkg/scrape/network.go

@@ -5,15 +5,10 @@ import (
 
 	"github.com/opencost/opencost/core/pkg/clustercache"
 	"github.com/opencost/opencost/core/pkg/log"
+	"github.com/opencost/opencost/modules/collector-source/pkg/metric"
 	"github.com/opencost/opencost/modules/collector-source/pkg/scrape/target"
 )
 
-// Network Metrics
-const (
-	KubecostPodNetworkEgressBytesTotal  = "kubecost_pod_network_egress_bytes_total"
-	KubecostPodNetworkIngressBytesTotal = "kubecost_pod_network_ingress_bytes_total"
-)
-
 func newNetworkScraper(
 	port int,
 	clusterCache clustercache.ClusterCache,
@@ -26,8 +21,8 @@ func newNetworkTargetScraper(provider target.TargetProvider) *TargetScraper {
 	return newTargetScrapper(
 		provider,
 		[]string{
-			KubecostPodNetworkEgressBytesTotal,
-			KubecostPodNetworkIngressBytesTotal,
+			metric.KubecostPodNetworkEgressBytesTotal,
+			metric.KubecostPodNetworkIngressBytesTotal,
 		},
 		true)
 }

+ 17 - 36
modules/collector-source/pkg/scrape/opencost.go

@@ -1,29 +1,10 @@
 package scrape
 
 import (
+	"github.com/opencost/opencost/modules/collector-source/pkg/metric"
 	"github.com/opencost/opencost/modules/collector-source/pkg/scrape/target"
 )
 
-// Opencost Metrics
-const (
-	KubecostClusterManagementCost     = "kubecost_cluster_management_cost"
-	KubecostNetworkZoneEgressCost     = "kubecost_network_zone_egress_cost"
-	KubecostNetworkRegionEgressCost   = "kubecost_network_region_egress_cost"
-	KubecostNetworkInternetEgressCost = "kubecost_network_internet_egress_cost"
-	PVHourlyCost                      = "pv_hourly_cost"
-	KubecostLoadBalancerCost          = "kubecost_load_balancer_cost"
-	NodeTotalHourlyCost               = "node_total_hourly_cost"
-	NodeCPUHourlyCost                 = "node_cpu_hourly_cost"
-	NodeRAMHourlyCost                 = "node_ram_hourly_cost"
-	NodeGPUHourlyCost                 = "node_gpu_hourly_cost"
-	NodeGPUCount                      = "node_gpu_count"
-	KubecostNodeIsSpot                = "kubecost_node_is_spot"
-	ContainerCPUAllocation            = "container_cpu_allocation"
-	ContainerMemoryAllocationBytes    = "container_memory_allocation_bytes"
-	ContainerGPUAllocation            = "container_gpu_allocation"
-	PodPVCAllocation                  = "pod_pvc_allocation"
-)
-
 func newOpenCostTargetProvider() target.TargetProvider {
 	// localhost is used here because we are hitting an endpoint of this container
 	return target.NewDefaultTargetProvider(target.NewUrlTarget("http://localhost:9003/metrics"))
@@ -37,22 +18,22 @@ func newOpencostTargetScraper(provider target.TargetProvider) *TargetScraper {
 	return newTargetScrapper(
 		provider,
 		[]string{
-			KubecostClusterManagementCost,
-			KubecostNetworkZoneEgressCost,
-			KubecostNetworkRegionEgressCost,
-			KubecostNetworkInternetEgressCost,
-			PVHourlyCost,
-			KubecostLoadBalancerCost,
-			NodeTotalHourlyCost,
-			NodeCPUHourlyCost,
-			NodeRAMHourlyCost,
-			NodeGPUHourlyCost,
-			NodeGPUCount,
-			KubecostNodeIsSpot,
-			ContainerCPUAllocation,
-			ContainerMemoryAllocationBytes,
-			ContainerGPUAllocation,
-			PodPVCAllocation,
+			metric.KubecostClusterManagementCost,
+			metric.KubecostNetworkZoneEgressCost,
+			metric.KubecostNetworkRegionEgressCost,
+			metric.KubecostNetworkInternetEgressCost,
+			metric.PVHourlyCost,
+			metric.KubecostLoadBalancerCost,
+			metric.NodeTotalHourlyCost,
+			metric.NodeCPUHourlyCost,
+			metric.NodeRAMHourlyCost,
+			metric.NodeGPUHourlyCost,
+			metric.NodeGPUCount,
+			metric.KubecostNodeIsSpot,
+			metric.ContainerCPUAllocation,
+			metric.ContainerMemoryAllocationBytes,
+			metric.ContainerGPUAllocation,
+			metric.PodPVCAllocation,
 		},
 		true)
 }

+ 8 - 20
modules/collector-source/pkg/scrape/statsummary.go

@@ -8,18 +8,6 @@ import (
 	stats "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
 )
 
-// Stat Summary Metrics
-const (
-	NodeCPUSecondsTotal                = "node_cpu_seconds_total"
-	NodeFSCapacityBytes                = "node_fs_capacity_bytes" // replaces container_fs_limit_bytes
-	ContainerNetworkReceiveBytesTotal  = "container_network_receive_bytes_total"
-	ContainerNetworkTransmitBytesTotal = "container_network_transmit_bytes_total"
-	ContainerCPUUsageSecondsTotal      = "container_cpu_usage_seconds_total"
-	ContainerMemoryWorkingSetBytes     = "container_memory_working_set_bytes"
-	ContainerFSUsageBytes              = "container_fs_usage_bytes"
-	KubeletVolumeStatsUsedBytes        = "kubelet_volume_stats_used_bytes"
-)
-
 type StatSummaryScraper struct {
 	client nodestats.StatSummaryClient
 }
@@ -45,7 +33,7 @@ func (s *StatSummaryScraper) Scrape() []metric.Update {
 		nodeName := stat.Node.NodeName
 		if stat.Node.CPU != nil && stat.Node.CPU.UsageCoreNanoSeconds != nil {
 			scrapeResults = append(scrapeResults, metric.Update{
-				Name: NodeCPUSecondsTotal,
+				Name: metric.NodeCPUSecondsTotal,
 				Labels: map[string]string{
 					source.KubernetesNodeLabel: nodeName,
 					source.ModeLabel:           "", // TODO
@@ -56,7 +44,7 @@ func (s *StatSummaryScraper) Scrape() []metric.Update {
 
 		if stat.Node.Fs != nil && stat.Node.Fs.CapacityBytes != nil {
 			scrapeResults = append(scrapeResults, metric.Update{
-				Name: NodeFSCapacityBytes,
+				Name: metric.NodeFSCapacityBytes,
 				Labels: map[string]string{
 					source.InstanceLabel: nodeName,
 					source.DeviceLabel:   "local", // This value has to be populated but isn't important here
@@ -96,7 +84,7 @@ func (s *StatSummaryScraper) Scrape() []metric.Update {
 					continue
 				}
 				scrapeResults = append(scrapeResults, metric.Update{
-					Name: KubeletVolumeStatsUsedBytes,
+					Name: metric.KubeletVolumeStatsUsedBytes,
 					Labels: map[string]string{
 						source.PVCLabel:       volumeStats.PVCRef.Name,
 						source.NamespaceLabel: volumeStats.PVCRef.Namespace,
@@ -109,7 +97,7 @@ func (s *StatSummaryScraper) Scrape() []metric.Update {
 			for _, container := range pod.Containers {
 				if container.CPU != nil && container.CPU.UsageCoreNanoSeconds != nil {
 					scrapeResults = append(scrapeResults, metric.Update{
-						Name: ContainerCPUUsageSecondsTotal,
+						Name: metric.ContainerCPUUsageSecondsTotal,
 						Labels: map[string]string{
 							source.ContainerLabel: container.Name,
 							source.PodLabel:       podName,
@@ -122,7 +110,7 @@ func (s *StatSummaryScraper) Scrape() []metric.Update {
 				}
 				if container.Memory != nil && container.Memory.WorkingSetBytes != nil {
 					scrapeResults = append(scrapeResults, metric.Update{
-						Name: ContainerMemoryWorkingSetBytes,
+						Name: metric.ContainerMemoryWorkingSetBytes,
 						Labels: map[string]string{
 							source.ContainerLabel: container.Name,
 							source.PodLabel:       podName,
@@ -136,7 +124,7 @@ func (s *StatSummaryScraper) Scrape() []metric.Update {
 
 				if container.Rootfs != nil && container.Rootfs.UsedBytes != nil {
 					scrapeResults = append(scrapeResults, metric.Update{
-						Name: ContainerFSUsageBytes,
+						Name: metric.ContainerFSUsageBytes,
 						Labels: map[string]string{
 							source.InstanceLabel: nodeName,
 							source.DeviceLabel:   "local",
@@ -157,7 +145,7 @@ func scrapeNetworkStats(scrapeResults *[]metric.Update, labels map[string]string
 	}
 	if networkStats.RxBytes != nil {
 		*scrapeResults = append(*scrapeResults, metric.Update{
-			Name:   ContainerNetworkReceiveBytesTotal,
+			Name:   metric.ContainerNetworkReceiveBytesTotal,
 			Labels: labels,
 			Value:  float64(*networkStats.RxBytes),
 		})
@@ -165,7 +153,7 @@ func scrapeNetworkStats(scrapeResults *[]metric.Update, labels map[string]string
 
 	if networkStats.TxBytes != nil {
 		*scrapeResults = append(*scrapeResults, metric.Update{
-			Name:   ContainerNetworkTransmitBytesTotal,
+			Name:   metric.ContainerNetworkTransmitBytesTotal,
 			Labels: labels,
 			Value:  float64(*networkStats.TxBytes),
 		})

+ 9 - 9
modules/collector-source/pkg/scrape/statsummary_test.go

@@ -192,7 +192,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: NodeCPUSecondsTotal,
+					Name: metric.NodeCPUSecondsTotal,
 					Labels: map[string]string{
 						source.KubernetesNodeLabel: "node1",
 						source.ModeLabel:           "",
@@ -200,7 +200,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 					Value: 2,
 				},
 				{
-					Name: NodeFSCapacityBytes,
+					Name: metric.NodeFSCapacityBytes,
 					Labels: map[string]string{
 						source.InstanceLabel: "node1",
 						source.DeviceLabel:   "local",
@@ -208,7 +208,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 					Value: float64(2 * util.GB),
 				},
 				{
-					Name: ContainerNetworkReceiveBytesTotal,
+					Name: metric.ContainerNetworkReceiveBytesTotal,
 					Labels: map[string]string{
 						source.UIDLabel:       "uid1",
 						source.PodLabel:       "pod1",
@@ -217,7 +217,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 					Value: float64(1 * util.MB),
 				},
 				{
-					Name: ContainerNetworkTransmitBytesTotal,
+					Name: metric.ContainerNetworkTransmitBytesTotal,
 					Labels: map[string]string{
 						source.UIDLabel:       "uid1",
 						source.PodLabel:       "pod1",
@@ -226,7 +226,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 					Value: float64(2 * util.MB),
 				},
 				{
-					Name: KubeletVolumeStatsUsedBytes,
+					Name: metric.KubeletVolumeStatsUsedBytes,
 					Labels: map[string]string{
 						source.PVCLabel:       "pvc1",
 						source.NamespaceLabel: "namespace1",
@@ -234,7 +234,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 					Value: float64(1 * util.GB),
 				},
 				{
-					Name: ContainerCPUUsageSecondsTotal,
+					Name: metric.ContainerCPUUsageSecondsTotal,
 					Labels: map[string]string{
 						source.ContainerLabel: "container1",
 						source.PodLabel:       "pod1",
@@ -245,7 +245,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 					Value: 1,
 				},
 				{
-					Name: ContainerMemoryWorkingSetBytes,
+					Name: metric.ContainerMemoryWorkingSetBytes,
 					Labels: map[string]string{
 						source.ContainerLabel: "container1",
 						source.PodLabel:       "pod1",
@@ -256,7 +256,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 					Value: float64(5 * util.MB),
 				},
 				{
-					Name: ContainerFSUsageBytes,
+					Name: metric.ContainerFSUsageBytes,
 					Labels: map[string]string{
 						source.InstanceLabel: "node1",
 						source.DeviceLabel:   "local",
@@ -317,7 +317,7 @@ func TestStatScraper_Scrape(t *testing.T) {
 			},
 			expected: []metric.Update{
 				{
-					Name: KubeletVolumeStatsUsedBytes,
+					Name: metric.KubeletVolumeStatsUsedBytes,
 					Labels: map[string]string{
 						source.PVCLabel:       "pvc1",
 						source.NamespaceLabel: "namespace1",

+ 33 - 33
modules/collector-source/pkg/scrape/targetscraper_test.go

@@ -113,7 +113,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 			targetScraperFactory: newNetworkTargetScraper,
 			expected: []metric.Update{
 				{
-					Name: KubecostPodNetworkEgressBytesTotal,
+					Name: metric.KubecostPodNetworkEgressBytesTotal,
 					Labels: map[string]string{
 						"pod_name":    "pod1",
 						"namespace":   "namespace1",
@@ -125,7 +125,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 3127969647,
 				},
 				{
-					Name: KubecostPodNetworkEgressBytesTotal,
+					Name: metric.KubecostPodNetworkEgressBytesTotal,
 					Labels: map[string]string{
 						"pod_name":    "pod2",
 						"namespace":   "namespace1",
@@ -137,7 +137,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 335188219,
 				},
 				{
-					Name: KubecostPodNetworkIngressBytesTotal,
+					Name: metric.KubecostPodNetworkIngressBytesTotal,
 					Labels: map[string]string{
 						"pod_name":    "pod1",
 						"namespace":   "namespace1",
@@ -149,7 +149,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 17941460,
 				},
 				{
-					Name: KubecostPodNetworkIngressBytesTotal,
+					Name: metric.KubecostPodNetworkIngressBytesTotal,
 					Labels: map[string]string{
 						"pod_name":    "pod2",
 						"namespace":   "namespace1",
@@ -168,26 +168,26 @@ func TestTargetScraper_Scrape(t *testing.T) {
 			targetScraperFactory: newOpencostTargetScraper,
 			expected: []metric.Update{
 				{
-					Name: KubecostClusterManagementCost,
+					Name: metric.KubecostClusterManagementCost,
 					Labels: map[string]string{
 						"provisioner_name": "GKE",
 					},
 					Value: 0.1,
 				},
 				{
-					Name:  KubecostNetworkZoneEgressCost,
+					Name:  metric.KubecostNetworkZoneEgressCost,
 					Value: 0.01,
 				},
 				{
-					Name:  KubecostNetworkRegionEgressCost,
+					Name:  metric.KubecostNetworkRegionEgressCost,
 					Value: 0.01,
 				},
 				{
-					Name:  KubecostNetworkInternetEgressCost,
+					Name:  metric.KubecostNetworkInternetEgressCost,
 					Value: 0.12,
 				},
 				{
-					Name: PVHourlyCost,
+					Name: metric.PVHourlyCost,
 					Labels: map[string]string{
 						"persistentvolume": "pvc-1",
 						"provider_id":      "pvc-1",
@@ -196,7 +196,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 5.479452054794521e-05,
 				},
 				{
-					Name: PVHourlyCost,
+					Name: metric.PVHourlyCost,
 					Labels: map[string]string{
 						"persistentvolume": "pvc-2",
 						"provider_id":      "pvc-2",
@@ -205,7 +205,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 5.479452054794521e-05,
 				},
 				{
-					Name: KubecostLoadBalancerCost,
+					Name: metric.KubecostLoadBalancerCost,
 					Labels: map[string]string{
 						"ingress_ip":   "127.0.0.1",
 						"namespace":    "namespace1",
@@ -214,7 +214,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.025,
 				},
 				{
-					Name: NodeTotalHourlyCost,
+					Name: metric.NodeTotalHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node1",
@@ -226,7 +226,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.06631302438846588,
 				},
 				{
-					Name: NodeTotalHourlyCost,
+					Name: metric.NodeTotalHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node2",
@@ -238,7 +238,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.06631302438846588,
 				},
 				{
-					Name: NodeCPUHourlyCost,
+					Name: metric.NodeCPUHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node1",
@@ -250,7 +250,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.021811590000000002,
 				},
 				{
-					Name: NodeCPUHourlyCost,
+					Name: metric.NodeCPUHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node2",
@@ -262,7 +262,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.021811590000000002,
 				},
 				{
-					Name: NodeRAMHourlyCost,
+					Name: metric.NodeRAMHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node1",
@@ -274,7 +274,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.00292353,
 				},
 				{
-					Name: NodeRAMHourlyCost,
+					Name: metric.NodeRAMHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node2",
@@ -286,7 +286,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.00292353,
 				},
 				{
-					Name: NodeGPUHourlyCost,
+					Name: metric.NodeGPUHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node1",
@@ -298,7 +298,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: NodeGPUHourlyCost,
+					Name: metric.NodeGPUHourlyCost,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node2",
@@ -310,7 +310,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: NodeGPUCount,
+					Name: metric.NodeGPUCount,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node1",
@@ -322,7 +322,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: NodeGPUCount,
+					Name: metric.NodeGPUCount,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node2",
@@ -334,7 +334,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: KubecostNodeIsSpot,
+					Name: metric.KubecostNodeIsSpot,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node1",
@@ -346,7 +346,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: KubecostNodeIsSpot,
+					Name: metric.KubecostNodeIsSpot,
 					Labels: map[string]string{
 						"arch":          "amd64",
 						"instance":      "node2",
@@ -358,7 +358,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: ContainerCPUAllocation,
+					Name: metric.ContainerCPUAllocation,
 					Labels: map[string]string{
 						"container": "container1",
 						"instance":  "node1",
@@ -369,7 +369,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.02,
 				},
 				{
-					Name: ContainerCPUAllocation,
+					Name: metric.ContainerCPUAllocation,
 					Labels: map[string]string{
 						"container": "container2",
 						"instance":  "node2",
@@ -380,7 +380,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.01,
 				},
 				{
-					Name: ContainerMemoryAllocationBytes,
+					Name: metric.ContainerMemoryAllocationBytes,
 					Labels: map[string]string{
 						"container": "container1",
 						"instance":  "node1",
@@ -391,7 +391,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 1.1528192e+07,
 				},
 				{
-					Name: ContainerMemoryAllocationBytes,
+					Name: metric.ContainerMemoryAllocationBytes,
 					Labels: map[string]string{
 						"container": "container2",
 						"instance":  "node2",
@@ -402,7 +402,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 1e+07,
 				},
 				{
-					Name: ContainerGPUAllocation,
+					Name: metric.ContainerGPUAllocation,
 					Labels: map[string]string{
 						"container": "container1",
 						"instance":  "node1",
@@ -413,7 +413,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: ContainerGPUAllocation,
+					Name: metric.ContainerGPUAllocation,
 					Labels: map[string]string{
 						"container": "container2",
 						"instance":  "node2",
@@ -424,7 +424,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0,
 				},
 				{
-					Name: PodPVCAllocation,
+					Name: metric.PodPVCAllocation,
 					Labels: map[string]string{
 						"namespace":             "namespace1",
 						"persistentvolume":      "pvc-1",
@@ -434,7 +434,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 3.4359738368e+10,
 				},
 				{
-					Name: PodPVCAllocation,
+					Name: metric.PodPVCAllocation,
 					Labels: map[string]string{
 						"namespace":             "namespace1",
 						"persistentvolume":      "pvc-2",
@@ -451,7 +451,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 			targetScraperFactory: newDCGMTargetScraper,
 			expected: []metric.Update{
 				{
-					Name: DCGMFIPROFGRENGINEACTIVE,
+					Name: metric.DCGMFIPROFGRENGINEACTIVE,
 					Labels: map[string]string{
 						"gpu":        "0",
 						"UUID":       "GPU-1",
@@ -463,7 +463,7 @@ func TestTargetScraper_Scrape(t *testing.T) {
 					Value: 0.999999,
 				},
 				{
-					Name: DCGMFIDEVDECUTIL,
+					Name: metric.DCGMFIDEVDECUTIL,
 					Labels: map[string]string{
 						"gpu":        "0",
 						"UUID":       "GPU-1",