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

Further simplification of Query APIs

Signed-off-by: Matt Bolt <mbolt35@gmail.com>
Matt Bolt 1 год назад
Родитель
Сommit
b1d9e9e9c6

+ 26 - 27
core/pkg/source/datasource.go

@@ -9,45 +9,36 @@ import (
 
 
 type ClusterMetricsQuerier interface {
 type ClusterMetricsQuerier interface {
 	// Cluster Disks
 	// Cluster Disks
-	QueryPVCost(start, end time.Time) QueryResultsChan
-	QueryPVSize(start, end time.Time) QueryResultsChan
-	QueryPVStorageClass(start, end time.Time) QueryResultsChan
+	QueryPVActiveMinutes(start, end time.Time) QueryResultsChan
 	QueryPVUsedAverage(start, end time.Time) QueryResultsChan
 	QueryPVUsedAverage(start, end time.Time) QueryResultsChan
 	QueryPVUsedMax(start, end time.Time) QueryResultsChan
 	QueryPVUsedMax(start, end time.Time) QueryResultsChan
-	QueryPVCInfo(start, end time.Time) QueryResultsChan
-	QueryPVActiveMinutes(start, end time.Time) QueryResultsChan
 
 
 	// Local Cluster Disks
 	// Local Cluster Disks
+	QueryLocalStorageActiveMinutes(start, end time.Time) QueryResultsChan
 	QueryLocalStorageCost(start, end time.Time) QueryResultsChan
 	QueryLocalStorageCost(start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedCost(start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedCost(start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedAvg(start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedAvg(start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedMax(start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedMax(start, end time.Time) QueryResultsChan
 	QueryLocalStorageBytes(start, end time.Time) QueryResultsChan
 	QueryLocalStorageBytes(start, end time.Time) QueryResultsChan
-	QueryLocalStorageActiveMinutes(start, end time.Time) QueryResultsChan
 	QueryLocalStorageBytesByProvider(provider string, start, end time.Time) QueryResultsChan
 	QueryLocalStorageBytesByProvider(provider string, start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedByProvider(provider string, start, end time.Time) QueryResultsChan
 	QueryLocalStorageUsedByProvider(provider string, start, end time.Time) QueryResultsChan
 
 
 	// Nodes
 	// Nodes
-	QueryNodeCPUHourlyCost(start, end time.Time) QueryResultsChan // Duplicate: QueryNodeCostPerCPUHr
+	QueryNodeActiveMinutes(start, end time.Time) QueryResultsChan
 	QueryNodeCPUCoresCapacity(start, end time.Time) QueryResultsChan
 	QueryNodeCPUCoresCapacity(start, end time.Time) QueryResultsChan
 	QueryNodeCPUCoresAllocatable(start, end time.Time) QueryResultsChan
 	QueryNodeCPUCoresAllocatable(start, end time.Time) QueryResultsChan
-	QueryNodeRAMHourlyCost(start, end time.Time) QueryResultsChan // Duplicate: QueryNodeCostPerRAMHr
 	QueryNodeRAMBytesCapacity(start, end time.Time) QueryResultsChan
 	QueryNodeRAMBytesCapacity(start, end time.Time) QueryResultsChan
 	QueryNodeRAMBytesAllocatable(start, end time.Time) QueryResultsChan
 	QueryNodeRAMBytesAllocatable(start, end time.Time) QueryResultsChan
 	QueryNodeGPUCount(start, end time.Time) QueryResultsChan
 	QueryNodeGPUCount(start, end time.Time) QueryResultsChan
-	QueryNodeGPUHourlyCost(start, end time.Time) QueryResultsChan // Duplicate: QueryNodeCostPerGPUHr
-	QueryNodeLabels(start, end time.Time) QueryResultsChan
-	QueryNodeActiveMinutes(start, end time.Time) QueryResultsChan
-	QueryNodeIsSpot(start, end time.Time) QueryResultsChan
 	QueryNodeCPUModeTotal(start, end time.Time) QueryResultsChan
 	QueryNodeCPUModeTotal(start, end time.Time) QueryResultsChan
-
+	QueryNodeIsSpot(start, end time.Time) QueryResultsChan
 	QueryNodeCPUModePercent(start, end time.Time) QueryResultsChan
 	QueryNodeCPUModePercent(start, end time.Time) QueryResultsChan
 	QueryNodeRAMSystemPercent(start, end time.Time) QueryResultsChan
 	QueryNodeRAMSystemPercent(start, end time.Time) QueryResultsChan
 	QueryNodeRAMUserPercent(start, end time.Time) QueryResultsChan
 	QueryNodeRAMUserPercent(start, end time.Time) QueryResultsChan
 
 
 	// Load Balancers
 	// Load Balancers
-	QueryLBPricePerHr(start, end time.Time) QueryResultsChan
 	QueryLBActiveMinutes(start, end time.Time) QueryResultsChan
 	QueryLBActiveMinutes(start, end time.Time) QueryResultsChan
+	QueryLBPricePerHr(start, end time.Time) QueryResultsChan
 
 
 	// Cluster Management
 	// Cluster Management
 	QueryClusterManagementDuration(start, end time.Time) QueryResultsChan
 	QueryClusterManagementDuration(start, end time.Time) QueryResultsChan
@@ -74,29 +65,35 @@ type ClusterMetricsQuerier interface {
 type AllocationMetricsQuerier interface {
 type AllocationMetricsQuerier interface {
 	QueryPods(start, end time.Time) QueryResultsChan
 	QueryPods(start, end time.Time) QueryResultsChan
 	QueryPodsUID(start, end time.Time) QueryResultsChan
 	QueryPodsUID(start, end time.Time) QueryResultsChan
+
 	QueryRAMBytesAllocated(start, end time.Time) QueryResultsChan
 	QueryRAMBytesAllocated(start, end time.Time) QueryResultsChan
 	QueryRAMRequests(start, end time.Time) QueryResultsChan
 	QueryRAMRequests(start, end time.Time) QueryResultsChan
 	QueryRAMUsageAvg(start, end time.Time) QueryResultsChan
 	QueryRAMUsageAvg(start, end time.Time) QueryResultsChan
 	QueryRAMUsageMax(start, end time.Time) QueryResultsChan
 	QueryRAMUsageMax(start, end time.Time) QueryResultsChan
+	QueryNodeRAMPricePerGiBHr(start, end time.Time) QueryResultsChan
+
 	QueryCPUCoresAllocated(start, end time.Time) QueryResultsChan
 	QueryCPUCoresAllocated(start, end time.Time) QueryResultsChan
 	QueryCPURequests(start, end time.Time) QueryResultsChan
 	QueryCPURequests(start, end time.Time) QueryResultsChan
 	QueryCPUUsageAvg(start, end time.Time) QueryResultsChan
 	QueryCPUUsageAvg(start, end time.Time) QueryResultsChan
 	QueryCPUUsageMax(start, end time.Time) QueryResultsChan
 	QueryCPUUsageMax(start, end time.Time) QueryResultsChan
+	QueryNodeCPUPricePerHr(start, end time.Time) QueryResultsChan
+
+	QueryGPUsAllocated(start, end time.Time) QueryResultsChan
 	QueryGPUsRequested(start, end time.Time) QueryResultsChan
 	QueryGPUsRequested(start, end time.Time) QueryResultsChan
 	QueryGPUsUsageAvg(start, end time.Time) QueryResultsChan
 	QueryGPUsUsageAvg(start, end time.Time) QueryResultsChan
 	QueryGPUsUsageMax(start, end time.Time) QueryResultsChan
 	QueryGPUsUsageMax(start, end time.Time) QueryResultsChan
-	QueryGPUsAllocated(start, end time.Time) QueryResultsChan
-	QueryNodeCostPerCPUHr(start, end time.Time) QueryResultsChan
-	QueryNodeCostPerRAMGiBHr(start, end time.Time) QueryResultsChan
-	QueryNodeCostPerGPUHr(start, end time.Time) QueryResultsChan
-	QueryNodeIsSpot2(start, end time.Time) QueryResultsChan
-	QueryPVCInfo2(start, end time.Time) QueryResultsChan
+	QueryNodeGPUPricePerHr(start, end time.Time) QueryResultsChan
+	QueryGPUInfo(start, end time.Time) QueryResultsChan
+	QueryIsGPUShared(start, end time.Time) QueryResultsChan
+
 	QueryPodPVCAllocation(start, end time.Time) QueryResultsChan
 	QueryPodPVCAllocation(start, end time.Time) QueryResultsChan
 	QueryPVCBytesRequested(start, end time.Time) QueryResultsChan
 	QueryPVCBytesRequested(start, end time.Time) QueryResultsChan
-	QueryPVActiveMins(start, end time.Time) QueryResultsChan
+	QueryPVCInfo(start, end time.Time) QueryResultsChan
+
 	QueryPVBytes(start, end time.Time) QueryResultsChan
 	QueryPVBytes(start, end time.Time) QueryResultsChan
-	QueryPVCostPerGiBHour(start, end time.Time) QueryResultsChan
-	QueryPVMeta(start, end time.Time) QueryResultsChan
+	QueryPVPricePerGiBHour(start, end time.Time) QueryResultsChan
+	QueryPVInfo(start, end time.Time) QueryResultsChan
+
 	QueryNetZoneGiB(start, end time.Time) QueryResultsChan
 	QueryNetZoneGiB(start, end time.Time) QueryResultsChan
 	QueryNetZoneCostPerGiB(start, end time.Time) QueryResultsChan
 	QueryNetZoneCostPerGiB(start, end time.Time) QueryResultsChan
 	QueryNetRegionGiB(start, end time.Time) QueryResultsChan
 	QueryNetRegionGiB(start, end time.Time) QueryResultsChan
@@ -105,22 +102,24 @@ type AllocationMetricsQuerier interface {
 	QueryNetInternetCostPerGiB(start, end time.Time) QueryResultsChan
 	QueryNetInternetCostPerGiB(start, end time.Time) QueryResultsChan
 	QueryNetReceiveBytes(start, end time.Time) QueryResultsChan
 	QueryNetReceiveBytes(start, end time.Time) QueryResultsChan
 	QueryNetTransferBytes(start, end time.Time) QueryResultsChan
 	QueryNetTransferBytes(start, end time.Time) QueryResultsChan
+
+	QueryNamespaceAnnotations(start, end time.Time) QueryResultsChan
+	QueryPodAnnotations(start, end time.Time) QueryResultsChan
+
 	QueryNodeLabels(start, end time.Time) QueryResultsChan
 	QueryNodeLabels(start, end time.Time) QueryResultsChan
 	QueryNamespaceLabels(start, end time.Time) QueryResultsChan
 	QueryNamespaceLabels(start, end time.Time) QueryResultsChan
-	QueryNamespaceAnnotations(start, end time.Time) QueryResultsChan
 	QueryPodLabels(start, end time.Time) QueryResultsChan
 	QueryPodLabels(start, end time.Time) QueryResultsChan
-	QueryPodAnnotations(start, end time.Time) QueryResultsChan
 	QueryServiceLabels(start, end time.Time) QueryResultsChan
 	QueryServiceLabels(start, end time.Time) QueryResultsChan
 	QueryDeploymentLabels(start, end time.Time) QueryResultsChan
 	QueryDeploymentLabels(start, end time.Time) QueryResultsChan
 	QueryStatefulSetLabels(start, end time.Time) QueryResultsChan
 	QueryStatefulSetLabels(start, end time.Time) QueryResultsChan
 	QueryDaemonSetLabels(start, end time.Time) QueryResultsChan
 	QueryDaemonSetLabels(start, end time.Time) QueryResultsChan
 	QueryJobLabels(start, end time.Time) QueryResultsChan
 	QueryJobLabels(start, end time.Time) QueryResultsChan
+
 	QueryPodsWithReplicaSetOwner(start, end time.Time) QueryResultsChan
 	QueryPodsWithReplicaSetOwner(start, end time.Time) QueryResultsChan
 	QueryReplicaSetsWithoutOwners(start, end time.Time) QueryResultsChan
 	QueryReplicaSetsWithoutOwners(start, end time.Time) QueryResultsChan
 	QueryReplicaSetsWithRollout(start, end time.Time) QueryResultsChan
 	QueryReplicaSetsWithRollout(start, end time.Time) QueryResultsChan
+
 	QueryDataCoverage(limitDays int) (time.Time, time.Time, error)
 	QueryDataCoverage(limitDays int) (time.Time, time.Time, error)
-	QueryIsGPUShared(start, end time.Time) QueryResultsChan
-	QueryGetGPUInfo(start, end time.Time) QueryResultsChan
 }
 }
 
 
 type OpenCostDataSource interface {
 type OpenCostDataSource interface {

+ 70 - 203
modules/prometheus-source/pkg/prom/datasource.go

@@ -600,8 +600,8 @@ func (pds *PrometheusDataSource) MetaData() map[string]string {
 //  InstantMetricsQuerier
 //  InstantMetricsQuerier
 //--------------------------------------------------------------------------
 //--------------------------------------------------------------------------
 
 
-func (pds *PrometheusDataSource) QueryPVCost(start, end time.Time) source.QueryResultsChan {
-	const pvCostQuery = `avg(avg_over_time(pv_hourly_cost{%s}[%s])) by (%s, persistentvolume,provider_id)`
+func (pds *PrometheusDataSource) QueryPVPricePerGiBHour(start, end time.Time) source.QueryResultsChan {
+	const pvCostQuery = `avg(avg_over_time(pv_hourly_cost{%s}[%s])) by (%s, persistentvolume, volumename, provider_id)`
 
 
 	durStr := timeutil.DurationString(end.Sub(start))
 	durStr := timeutil.DurationString(end.Sub(start))
 	if durStr == "" {
 	if durStr == "" {
@@ -614,38 +614,6 @@ func (pds *PrometheusDataSource) QueryPVCost(start, end time.Time) source.QueryR
 	return ctx.QueryAtTime(queryPVCost, end)
 	return ctx.QueryAtTime(queryPVCost, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryPVSize(start, end time.Time) source.QueryResultsChan {
-	const pvSizeQuery = `avg(avg_over_time(kube_persistentvolume_capacity_bytes{%s}[%s])) by (%s, persistentvolume)`
-
-	cfg := pds.promConfig
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryPVCost")
-	}
-
-	queryPVSize := fmt.Sprintf(pvSizeQuery, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
-
-	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
-	return ctx.QueryAtTime(queryPVSize, end)
-}
-
-func (pds *PrometheusDataSource) QueryPVStorageClass(start, end time.Time) source.QueryResultsChan {
-	// `avg(avg_over_time(kubecost_pv_info{%s}[%s])) by (%s, persistentvolume, storageclass)`
-	// , env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
-
-	const pvStorageSizeQuery = `avg(avg_over_time(kubecost_pv_info{%s}[%s])) by (%s, persistentvolume, storageclass)`
-	cfg := pds.promConfig
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryPVStorageClass")
-	}
-
-	queryPVStorageClass := fmt.Sprintf(pvStorageSizeQuery, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
-	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
-	return ctx.QueryAtTime(queryPVStorageClass, end)
-}
-
 func (pds *PrometheusDataSource) QueryPVUsedAverage(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryPVUsedAverage(start, end time.Time) source.QueryResultsChan {
 	// `avg(avg_over_time(kubelet_volume_stats_used_bytes{%s}[%s])) by (%s, persistentvolumeclaim, namespace)`
 	// `avg(avg_over_time(kubelet_volume_stats_used_bytes{%s}[%s])) by (%s, persistentvolumeclaim, namespace)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
@@ -680,11 +648,13 @@ func (pds *PrometheusDataSource) QueryPVUsedMax(start, end time.Time) source.Que
 	return ctx.QueryAtTime(queryPVUsedMax, end)
 	return ctx.QueryAtTime(queryPVUsedMax, end)
 }
 }
 
 
+/*
 func (pds *PrometheusDataSource) QueryPVCInfo(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryPVCInfo(start, end time.Time) source.QueryResultsChan {
 	// `avg(avg_over_time(kube_persistentvolumeclaim_info{%s}[%s])) by (%s, volumename, persistentvolumeclaim, namespace)`
 	// `avg(avg_over_time(kube_persistentvolumeclaim_info{%s}[%s])) by (%s, volumename, persistentvolumeclaim, namespace)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
 	const pvcInfoQuery = `avg(avg_over_time(kube_persistentvolumeclaim_info{%s}[%s])) by (%s, volumename, persistentvolumeclaim, namespace)`
 	const pvcInfoQuery = `avg(avg_over_time(kube_persistentvolumeclaim_info{%s}[%s])) by (%s, volumename, persistentvolumeclaim, namespace)`
+
 	cfg := pds.promConfig
 	cfg := pds.promConfig
 
 
 	durStr := timeutil.DurationString(end.Sub(start))
 	durStr := timeutil.DurationString(end.Sub(start))
@@ -696,11 +666,29 @@ func (pds *PrometheusDataSource) QueryPVCInfo(start, end time.Time) source.Query
 	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
 	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
 	return ctx.QueryAtTime(queryPVCInfo, end)
 	return ctx.QueryAtTime(queryPVCInfo, end)
 }
 }
+*/
+
+func (pds *PrometheusDataSource) QueryPVCInfo(start, end time.Time) source.QueryResultsChan {
+	const queryFmtPVCInfo = `avg(kube_persistentvolumeclaim_info{volumename != "", %s}) by (persistentvolumeclaim, storageclass, volumename, namespace, %s)[%s:%s]`
+	// env.GetPromClusterFilter(), env.GetPromClusterLabel(), durStr, resStr)
+
+	cfg := pds.promConfig
+	resolution := cfg.DataResolution
+	resStr := timeutil.DurationString(resolution)
+
+	durStr := timeutil.DurationString(end.Sub(start))
+	if durStr == "" {
+		panic("failed to parse duration string passed to QueryPVCInfo")
+	}
+
+	queryPVCInfo := fmt.Sprintf(queryFmtPVCInfo, cfg.ClusterFilter, cfg.ClusterLabel, durStr, resStr)
+	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
+	return ctx.QueryAtTime(queryPVCInfo, end)
+}
 
 
 func (pds *PrometheusDataSource) QueryPVActiveMinutes(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryPVActiveMinutes(start, end time.Time) source.QueryResultsChan {
-	// `avg(kube_persistentvolume_capacity_bytes{%s}) by (%s, persistentvolume)[%s:%dm]`
-	// env.GetPromClusterFilter(), env.GetPromClusterLabel(), durStr, minsPerResolution)
 	const pvActiveMinsQuery = `avg(kube_persistentvolume_capacity_bytes{%s}) by (%s, persistentvolume)[%s:%dm]`
 	const pvActiveMinsQuery = `avg(kube_persistentvolume_capacity_bytes{%s}) by (%s, persistentvolume)[%s:%dm]`
+	// env.GetPromClusterFilter(), env.GetPromClusterLabel(), durStr, minsPerResolution)
 
 
 	cfg := pds.promConfig
 	cfg := pds.promConfig
 	minsPerResolution := cfg.DataResolutionMinutes
 	minsPerResolution := cfg.DataResolutionMinutes
@@ -881,23 +869,6 @@ func (pds *PrometheusDataSource) QueryLocalStorageUsedByProvider(provider string
 	return ctx.QueryAtTime(localStorageUsedQuery, end)
 	return ctx.QueryAtTime(localStorageUsedQuery, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeCPUHourlyCost(start, end time.Time) source.QueryResultsChan {
-	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
-
-	const nodeCPUHourlyCostQuery = `avg(avg_over_time(node_cpu_hourly_cost{%s}[%s])) by (%s, node, instance_type, provider_id)`
-
-	cfg := pds.promConfig
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeCPUHourlyCost")
-	}
-
-	queryNodeCPUHourlyCost := fmt.Sprintf(nodeCPUHourlyCostQuery, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
-	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
-	return ctx.QueryAtTime(queryNodeCPUHourlyCost, end)
-}
-
 func (pds *PrometheusDataSource) QueryNodeCPUCoresCapacity(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryNodeCPUCoresCapacity(start, end time.Time) source.QueryResultsChan {
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
@@ -919,6 +890,7 @@ func (pds *PrometheusDataSource) QueryNodeCPUCoresAllocatable(start, end time.Ti
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
 	const nodeCPUCoresAllocatableQuery = `avg(avg_over_time(kube_node_status_allocatable_cpu_cores{%s}[%s])) by (%s, node)`
 	const nodeCPUCoresAllocatableQuery = `avg(avg_over_time(kube_node_status_allocatable_cpu_cores{%s}[%s])) by (%s, node)`
+	// `avg(avg_over_time(container_cpu_allocation{container!="", container!="POD", node!="", %s}[%s])) by (container, pod, namespace, node, %s)`
 
 
 	cfg := pds.promConfig
 	cfg := pds.promConfig
 
 
@@ -932,23 +904,6 @@ func (pds *PrometheusDataSource) QueryNodeCPUCoresAllocatable(start, end time.Ti
 	return ctx.QueryAtTime(queryNodeCPUCoresAllocatable, end)
 	return ctx.QueryAtTime(queryNodeCPUCoresAllocatable, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeRAMHourlyCost(start, end time.Time) source.QueryResultsChan {
-	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
-
-	const nodeRAMHourlyCostQuery = `avg(avg_over_time(node_ram_hourly_cost{%s}[%s])) by (%s, node, instance_type, provider_id) / 1024 / 1024 / 1024`
-
-	cfg := pds.promConfig
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeRAMHourlyCost")
-	}
-
-	queryNodeRAMHourlyCost := fmt.Sprintf(nodeRAMHourlyCostQuery, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
-	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
-	return ctx.QueryAtTime(queryNodeRAMHourlyCost, end)
-}
-
 func (pds *PrometheusDataSource) QueryNodeRAMBytesCapacity(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryNodeRAMBytesCapacity(start, end time.Time) source.QueryResultsChan {
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
@@ -1000,37 +955,18 @@ func (pds *PrometheusDataSource) QueryNodeGPUCount(start, end time.Time) source.
 	return ctx.QueryAtTime(queryNodeGPUCount, end)
 	return ctx.QueryAtTime(queryNodeGPUCount, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeGPUHourlyCost(start, end time.Time) source.QueryResultsChan {
-	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
-
-	const nodeGPUHourlyCostQuery = `avg(avg_over_time(node_gpu_hourly_cost{%s}[%s])) by (%s, node, instance_type, provider_id)`
-
-	cfg := pds.promConfig
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeGPUHourlyCost")
-	}
-
-	queryNodeGPUHourlyCost := fmt.Sprintf(nodeGPUHourlyCostQuery, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
-	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
-	return ctx.QueryAtTime(queryNodeGPUHourlyCost, end)
-}
-
 func (pds *PrometheusDataSource) QueryNodeLabels(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryNodeLabels(start, end time.Time) source.QueryResultsChan {
-	// env.GetPromClusterFilter(), durStr, minsPerResolution)
-
-	const labelsQuery = `count_over_time(kube_node_labels{%s}[%s:%dm])`
+	const labelsQuery = `avg_over_time(kube_node_labels{%s}[%s])`
+	// env.GetPromClusterFilter(), durStr
 
 
 	cfg := pds.promConfig
 	cfg := pds.promConfig
-	minsPerResolution := cfg.DataResolutionMinutes
 
 
 	durStr := timeutil.DurationString(end.Sub(start))
 	durStr := timeutil.DurationString(end.Sub(start))
 	if durStr == "" {
 	if durStr == "" {
 		panic("failed to parse duration string passed to QueryNodeLabels")
 		panic("failed to parse duration string passed to QueryNodeLabels")
 	}
 	}
 
 
-	queryLabels := fmt.Sprintf(labelsQuery, cfg.ClusterFilter, durStr, minsPerResolution)
+	queryLabels := fmt.Sprintf(labelsQuery, cfg.ClusterFilter, durStr)
 	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
 	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
 	return ctx.QueryAtTime(queryLabels, end)
 	return ctx.QueryAtTime(queryLabels, end)
 }
 }
@@ -1053,24 +989,6 @@ func (pds *PrometheusDataSource) QueryNodeActiveMinutes(start, end time.Time) so
 	return ctx.QueryAtTime(queryActiveMins, end)
 	return ctx.QueryAtTime(queryActiveMins, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeIsSpot(start, end time.Time) source.QueryResultsChan {
-	// env.GetPromClusterFilter(), durStr, minsPerResolution)
-
-	const isSpotQuery = `avg_over_time(kubecost_node_is_spot{%s}[%s:%dm])`
-
-	cfg := pds.promConfig
-	minsPerResolution := cfg.DataResolutionMinutes
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeIsSpot")
-	}
-
-	queryIsSpot := fmt.Sprintf(isSpotQuery, cfg.ClusterFilter, durStr, minsPerResolution)
-	ctx := pds.promContexts.NewNamedContext(ClusterContextName)
-	return ctx.QueryAtTime(queryIsSpot, end)
-}
-
 func (pds *PrometheusDataSource) QueryNodeCPUModeTotal(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryNodeCPUModeTotal(start, end time.Time) source.QueryResultsChan {
 	// env.GetPromClusterFilter(), durStr, minsPerResolution, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, minsPerResolution, env.GetPromClusterLabel())
 
 
@@ -1748,7 +1666,39 @@ func (pds *PrometheusDataSource) QueryGPUsAllocated(start, end time.Time) source
 	return ctx.QueryAtTime(queryGPUsAllocated, end)
 	return ctx.QueryAtTime(queryGPUsAllocated, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeCostPerCPUHr(start, end time.Time) source.QueryResultsChan {
+func (pds *PrometheusDataSource) QueryIsGPUShared(start, end time.Time) source.QueryResultsChan {
+	const queryFmtIsGPUShared = `avg(avg_over_time(kube_pod_container_resource_requests{container!="", node != "", pod != "", container!= "", unit = "integer",  %s}[%s])) by (container, pod, namespace, node, resource)`
+	// env.GetPromClusterFilter(), durStr
+
+	cfg := pds.promConfig
+
+	durStr := timeutil.DurationString(end.Sub(start))
+	if durStr == "" {
+		panic("failed to parse duration string passed to QueryIsGPUShared")
+	}
+
+	queryIsGPUShared := fmt.Sprintf(queryFmtIsGPUShared, cfg.ClusterFilter, durStr)
+	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
+	return ctx.QueryAtTime(queryIsGPUShared, end)
+}
+
+func (pds *PrometheusDataSource) QueryGPUInfo(start, end time.Time) source.QueryResultsChan {
+	const queryFmtGetGPUInfo = `avg(avg_over_time(DCGM_FI_DEV_DEC_UTIL{container!="",%s}[%s])) by (container, pod, namespace, device, modelName, UUID)`
+	// env.GetPromClusterFilter(), durStr
+
+	cfg := pds.promConfig
+
+	durStr := timeutil.DurationString(end.Sub(start))
+	if durStr == "" {
+		panic("failed to parse duration string passed to QueryGPUInfo")
+	}
+
+	queryGetGPUInfo := fmt.Sprintf(queryFmtGetGPUInfo, cfg.ClusterFilter, durStr)
+	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
+	return ctx.QueryAtTime(queryGetGPUInfo, end)
+}
+
+func (pds *PrometheusDataSource) QueryNodeCPUPricePerHr(start, end time.Time) source.QueryResultsChan {
 	const queryFmtNodeCostPerCPUHr = `avg(avg_over_time(node_cpu_hourly_cost{%s}[%s])) by (node, %s, instance_type, provider_id)`
 	const queryFmtNodeCostPerCPUHr = `avg(avg_over_time(node_cpu_hourly_cost{%s}[%s])) by (node, %s, instance_type, provider_id)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
@@ -1756,7 +1706,7 @@ func (pds *PrometheusDataSource) QueryNodeCostPerCPUHr(start, end time.Time) sou
 
 
 	durStr := timeutil.DurationString(end.Sub(start))
 	durStr := timeutil.DurationString(end.Sub(start))
 	if durStr == "" {
 	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeCostPerCPUHr")
+		panic("failed to parse duration string passed to QueryNodeCPUPricePerHr")
 	}
 	}
 
 
 	queryNodeCostPerCPUHr := fmt.Sprintf(queryFmtNodeCostPerCPUHr, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
 	queryNodeCostPerCPUHr := fmt.Sprintf(queryFmtNodeCostPerCPUHr, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
@@ -1764,7 +1714,7 @@ func (pds *PrometheusDataSource) QueryNodeCostPerCPUHr(start, end time.Time) sou
 	return ctx.QueryAtTime(queryNodeCostPerCPUHr, end)
 	return ctx.QueryAtTime(queryNodeCostPerCPUHr, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeCostPerRAMGiBHr(start, end time.Time) source.QueryResultsChan {
+func (pds *PrometheusDataSource) QueryNodeRAMPricePerGiBHr(start, end time.Time) source.QueryResultsChan {
 	const queryFmtNodeCostPerRAMGiBHr = `avg(avg_over_time(node_ram_hourly_cost{%s}[%s])) by (node, %s, instance_type, provider_id)`
 	const queryFmtNodeCostPerRAMGiBHr = `avg(avg_over_time(node_ram_hourly_cost{%s}[%s])) by (node, %s, instance_type, provider_id)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
@@ -1772,7 +1722,7 @@ func (pds *PrometheusDataSource) QueryNodeCostPerRAMGiBHr(start, end time.Time)
 
 
 	durStr := timeutil.DurationString(end.Sub(start))
 	durStr := timeutil.DurationString(end.Sub(start))
 	if durStr == "" {
 	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeCostPerRAMGiBHr")
+		panic("failed to parse duration string passed to QueryNodeRAMPricePerGiBHr")
 	}
 	}
 
 
 	queryNodeCostPerRAMGiBHr := fmt.Sprintf(queryFmtNodeCostPerRAMGiBHr, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
 	queryNodeCostPerRAMGiBHr := fmt.Sprintf(queryFmtNodeCostPerRAMGiBHr, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
@@ -1780,7 +1730,7 @@ func (pds *PrometheusDataSource) QueryNodeCostPerRAMGiBHr(start, end time.Time)
 	return ctx.QueryAtTime(queryNodeCostPerRAMGiBHr, end)
 	return ctx.QueryAtTime(queryNodeCostPerRAMGiBHr, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeCostPerGPUHr(start, end time.Time) source.QueryResultsChan {
+func (pds *PrometheusDataSource) QueryNodeGPUPricePerHr(start, end time.Time) source.QueryResultsChan {
 	const queryFmtNodeCostPerGPUHr = `avg(avg_over_time(node_gpu_hourly_cost{%s}[%s])) by (node, %s, instance_type, provider_id)`
 	const queryFmtNodeCostPerGPUHr = `avg(avg_over_time(node_gpu_hourly_cost{%s}[%s])) by (node, %s, instance_type, provider_id)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
@@ -1788,7 +1738,7 @@ func (pds *PrometheusDataSource) QueryNodeCostPerGPUHr(start, end time.Time) sou
 
 
 	durStr := timeutil.DurationString(end.Sub(start))
 	durStr := timeutil.DurationString(end.Sub(start))
 	if durStr == "" {
 	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeCostPerGPUHr")
+		panic("failed to parse duration string passed to QueryNodeGPUPricePerHr")
 	}
 	}
 
 
 	queryNodeCostPerGPUHr := fmt.Sprintf(queryFmtNodeCostPerGPUHr, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
 	queryNodeCostPerGPUHr := fmt.Sprintf(queryFmtNodeCostPerGPUHr, cfg.ClusterFilter, durStr, cfg.ClusterLabel)
@@ -1796,8 +1746,9 @@ func (pds *PrometheusDataSource) QueryNodeCostPerGPUHr(start, end time.Time) sou
 	return ctx.QueryAtTime(queryNodeCostPerGPUHr, end)
 	return ctx.QueryAtTime(queryNodeCostPerGPUHr, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeIsSpot2(start, end time.Time) source.QueryResultsChan {
+func (pds *PrometheusDataSource) QueryNodeIsSpot(start, end time.Time) source.QueryResultsChan {
 	const queryFmtNodeIsSpot = `avg_over_time(kubecost_node_is_spot{%s}[%s])`
 	const queryFmtNodeIsSpot = `avg_over_time(kubecost_node_is_spot{%s}[%s])`
+	//`avg_over_time(kubecost_node_is_spot{%s}[%s:%dm])`
 	// env.GetPromClusterFilter(), durStr)
 	// env.GetPromClusterFilter(), durStr)
 
 
 	cfg := pds.promConfig
 	cfg := pds.promConfig
@@ -1812,24 +1763,6 @@ func (pds *PrometheusDataSource) QueryNodeIsSpot2(start, end time.Time) source.Q
 	return ctx.QueryAtTime(queryNodeIsSpot, end)
 	return ctx.QueryAtTime(queryNodeIsSpot, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryPVCInfo2(start, end time.Time) source.QueryResultsChan {
-	const queryFmtPVCInfo = `avg(kube_persistentvolumeclaim_info{volumename != "", %s}) by (persistentvolumeclaim, storageclass, volumename, namespace, %s)[%s:%s]`
-	// env.GetPromClusterFilter(), env.GetPromClusterLabel(), durStr, resStr)
-
-	cfg := pds.promConfig
-	resolution := cfg.DataResolution
-	resStr := timeutil.DurationString(resolution)
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryPVCInfo2")
-	}
-
-	queryPVCInfo := fmt.Sprintf(queryFmtPVCInfo, cfg.ClusterFilter, cfg.ClusterLabel, durStr, resStr)
-	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
-	return ctx.QueryAtTime(queryPVCInfo, end)
-}
-
 func (pds *PrometheusDataSource) QueryPodPVCAllocation(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryPodPVCAllocation(start, end time.Time) source.QueryResultsChan {
 	const queryFmtPodPVCAllocation = `avg(avg_over_time(pod_pvc_allocation{%s}[%s])) by (persistentvolume, persistentvolumeclaim, pod, namespace, %s)`
 	const queryFmtPodPVCAllocation = `avg(avg_over_time(pod_pvc_allocation{%s}[%s])) by (persistentvolume, persistentvolumeclaim, pod, namespace, %s)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
@@ -1862,24 +1795,6 @@ func (pds *PrometheusDataSource) QueryPVCBytesRequested(start, end time.Time) so
 	return ctx.QueryAtTime(queryPVCBytesRequested, end)
 	return ctx.QueryAtTime(queryPVCBytesRequested, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryPVActiveMins(start, end time.Time) source.QueryResultsChan {
-	const queryFmtPVActiveMins = `count(kube_persistentvolume_capacity_bytes{%s}) by (persistentvolume, %s)[%s:%s]`
-	// env.GetPromClusterFilter(), env.GetPromClusterLabel(), durStr, resStr)
-
-	cfg := pds.promConfig
-	resolution := cfg.DataResolution
-	resStr := timeutil.DurationString(resolution)
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryPVActiveMins")
-	}
-
-	queryPVActiveMins := fmt.Sprintf(queryFmtPVActiveMins, cfg.ClusterFilter, cfg.ClusterLabel, durStr, resStr)
-	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
-	return ctx.QueryAtTime(queryPVActiveMins, end)
-}
-
 func (pds *PrometheusDataSource) QueryPVBytes(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryPVBytes(start, end time.Time) source.QueryResultsChan {
 	const queryFmtPVBytes = `avg(avg_over_time(kube_persistentvolume_capacity_bytes{%s}[%s])) by (persistentvolume, %s)`
 	const queryFmtPVBytes = `avg(avg_over_time(kube_persistentvolume_capacity_bytes{%s}[%s])) by (persistentvolume, %s)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
@@ -1912,8 +1827,8 @@ func (pds *PrometheusDataSource) QueryPVCostPerGiBHour(start, end time.Time) sou
 	return ctx.QueryAtTime(queryPVCostPerGiBHour, end)
 	return ctx.QueryAtTime(queryPVCostPerGiBHour, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryPVMeta(start, end time.Time) source.QueryResultsChan {
-	const queryFmtPVMeta = `avg(avg_over_time(kubecost_pv_info{%s}[%s])) by (%s, persistentvolume, provider_id)`
+func (pds *PrometheusDataSource) QueryPVInfo(start, end time.Time) source.QueryResultsChan {
+	const queryFmtPVMeta = `avg(avg_over_time(kubecost_pv_info{%s}[%s])) by (%s, storageclass, persistentvolume, provider_id)`
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 	// env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
 
 
 	cfg := pds.promConfig
 	cfg := pds.promConfig
@@ -2056,22 +1971,6 @@ func (pds *PrometheusDataSource) QueryNetTransferBytes(start, end time.Time) sou
 	return ctx.QueryAtTime(queryNetTransferBytes, end)
 	return ctx.QueryAtTime(queryNetTransferBytes, end)
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryNodeLabels2(start, end time.Time) source.QueryResultsChan {
-	const queryFmtNodeLabels = `avg_over_time(kube_node_labels{%s}[%s])`
-	// env.GetPromClusterFilter(), durStr
-
-	cfg := pds.promConfig
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryNodeLabels2")
-	}
-
-	queryNodeLabels := fmt.Sprintf(queryFmtNodeLabels, cfg.ClusterFilter, durStr)
-	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
-	return ctx.QueryAtTime(queryNodeLabels, end)
-}
-
 func (pds *PrometheusDataSource) QueryNamespaceLabels(start, end time.Time) source.QueryResultsChan {
 func (pds *PrometheusDataSource) QueryNamespaceLabels(start, end time.Time) source.QueryResultsChan {
 	const queryFmtNamespaceLabels = `avg_over_time(kube_namespace_labels{%s}[%s])`
 	const queryFmtNamespaceLabels = `avg_over_time(kube_namespace_labels{%s}[%s])`
 	// env.GetPromClusterFilter(), durStr
 	// env.GetPromClusterFilter(), durStr
@@ -2304,38 +2203,6 @@ func (pds *PrometheusDataSource) QueryDataCoverage(limitDays int) (time.Time, ti
 	return oldest, newest, nil
 	return oldest, newest, nil
 }
 }
 
 
-func (pds *PrometheusDataSource) QueryIsGPUShared(start, end time.Time) source.QueryResultsChan {
-	const queryFmtIsGPUShared = `avg(avg_over_time(kube_pod_container_resource_requests{container!="", node != "", pod != "", container!= "", unit = "integer",  %s}[%s])) by (container, pod, namespace, node, resource)`
-	// env.GetPromClusterFilter(), durStr
-
-	cfg := pds.promConfig
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryIsGPUShared")
-	}
-
-	queryIsGPUShared := fmt.Sprintf(queryFmtIsGPUShared, cfg.ClusterFilter, durStr)
-	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
-	return ctx.QueryAtTime(queryIsGPUShared, end)
-}
-
-func (pds *PrometheusDataSource) QueryGetGPUInfo(start, end time.Time) source.QueryResultsChan {
-	const queryFmtGetGPUInfo = `avg(avg_over_time(DCGM_FI_DEV_DEC_UTIL{container!="",%s}[%s])) by (container, pod, namespace, device, modelName, UUID)`
-	// env.GetPromClusterFilter(), durStr
-
-	cfg := pds.promConfig
-
-	durStr := timeutil.DurationString(end.Sub(start))
-	if durStr == "" {
-		panic("failed to parse duration string passed to QueryGetGPUInfo")
-	}
-
-	queryGetGPUInfo := fmt.Sprintf(queryFmtGetGPUInfo, cfg.ClusterFilter, durStr)
-	ctx := pds.promContexts.NewNamedContext(AllocationContextName)
-	return ctx.QueryAtTime(queryGetGPUInfo, end)
-}
-
 func newEmptyResult() source.QueryResultsChan {
 func newEmptyResult() source.QueryResultsChan {
 	ch := make(source.QueryResultsChan)
 	ch := make(source.QueryResultsChan)
 	go func() {
 	go func() {

+ 9 - 9
pkg/costmodel/allocation.go

@@ -308,21 +308,21 @@ func (cm *CostModel) computeAllocation(start, end time.Time, resolution time.Dur
 	resChGPUsRequested := grp.With(ds.QueryGPUsRequested(start, end))
 	resChGPUsRequested := grp.With(ds.QueryGPUsRequested(start, end))
 	resChGPUsUsageAvg := grp.With(ds.QueryGPUsUsageAvg(start, end))
 	resChGPUsUsageAvg := grp.With(ds.QueryGPUsUsageAvg(start, end))
 	resChGPUsUsageMax := grp.With(ds.QueryGPUsUsageMax(start, end))
 	resChGPUsUsageMax := grp.With(ds.QueryGPUsUsageMax(start, end))
-	resChGetGPUInfo := grp.With(ds.QueryGetGPUInfo(start, end))
+	resChGetGPUInfo := grp.With(ds.QueryGPUInfo(start, end))
 
 
-	resChNodeCostPerCPUHr := grp.With(ds.QueryNodeCostPerCPUHr(start, end))
-	resChNodeCostPerRAMGiBHr := grp.With(ds.QueryNodeCostPerRAMGiBHr(start, end))
-	resChNodeCostPerGPUHr := grp.With(ds.QueryNodeCostPerGPUHr(start, end))
+	resChNodeCostPerCPUHr := grp.With(ds.QueryNodeCPUPricePerHr(start, end))
+	resChNodeCostPerRAMGiBHr := grp.With(ds.QueryNodeRAMPricePerGiBHr(start, end))
+	resChNodeCostPerGPUHr := grp.With(ds.QueryNodeGPUPricePerHr(start, end))
 
 
-	resChNodeIsSpot := grp.With(ds.QueryNodeIsSpot2(start, end))
-	resChPVCInfo := grp.With(ds.QueryPVCInfo2(start, end))
+	resChNodeIsSpot := grp.With(ds.QueryNodeIsSpot(start, end))
+	resChPVCInfo := grp.With(ds.QueryPVCInfo(start, end))
 
 
 	resChPodPVCAllocation := grp.With(ds.QueryPodPVCAllocation(start, end))
 	resChPodPVCAllocation := grp.With(ds.QueryPodPVCAllocation(start, end))
 	resChPVCBytesRequested := grp.With(ds.QueryPVCBytesRequested(start, end))
 	resChPVCBytesRequested := grp.With(ds.QueryPVCBytesRequested(start, end))
-	resChPVActiveMins := grp.With(ds.QueryPVActiveMins(start, end))
+	resChPVActiveMins := grp.With(ds.QueryPVActiveMinutes(start, end))
 	resChPVBytes := grp.With(ds.QueryPVBytes(start, end))
 	resChPVBytes := grp.With(ds.QueryPVBytes(start, end))
-	resChPVCostPerGiBHour := grp.With(ds.QueryPVCostPerGiBHour(start, end))
-	resChPVMeta := grp.With(ds.QueryPVMeta(start, end))
+	resChPVCostPerGiBHour := grp.With(ds.QueryPVPricePerGiBHour(start, end))
+	resChPVMeta := grp.With(ds.QueryPVInfo(start, end))
 
 
 	resChNetTransferBytes := grp.With(ds.QueryNetTransferBytes(start, end))
 	resChNetTransferBytes := grp.With(ds.QueryNetTransferBytes(start, end))
 	resChNetReceiveBytes := grp.With(ds.QueryNetReceiveBytes(start, end))
 	resChNetReceiveBytes := grp.With(ds.QueryNetReceiveBytes(start, end))

+ 10 - 46
pkg/costmodel/cluster.go

@@ -132,10 +132,10 @@ func ClusterDisks(dataSource source.OpenCostDataSource, cp models.Provider, star
 
 
 	grp := source.NewQueryGroup()
 	grp := source.NewQueryGroup()
 
 
-	resChPVCost := grp.With(dataSource.QueryPVCost(start, end))
-	resChPVSize := grp.With(dataSource.QueryPVSize(start, end))
+	resChPVCost := grp.With(dataSource.QueryPVPricePerGiBHour(start, end))
+	resChPVSize := grp.With(dataSource.QueryPVBytes(start, end))
 	resChActiveMins := grp.With(dataSource.QueryPVActiveMinutes(start, end))
 	resChActiveMins := grp.With(dataSource.QueryPVActiveMinutes(start, end))
-	resChPVStorageClass := grp.With(dataSource.QueryPVStorageClass(start, end))
+	resChPVStorageClass := grp.With(dataSource.QueryPVInfo(start, end))
 	resChPVUsedAvg := grp.With(dataSource.QueryPVUsedAverage(start, end))
 	resChPVUsedAvg := grp.With(dataSource.QueryPVUsedAverage(start, end))
 	resChPVUsedMax := grp.With(dataSource.QueryPVUsedMax(start, end))
 	resChPVUsedMax := grp.With(dataSource.QueryPVUsedMax(start, end))
 	resChPVCInfo := grp.With(dataSource.QueryPVCInfo(start, end))
 	resChPVCInfo := grp.With(dataSource.QueryPVCInfo(start, end))
@@ -184,43 +184,7 @@ func ClusterDisks(dataSource source.OpenCostDataSource, cp models.Provider, star
 		return nil, grp.Error()
 		return nil, grp.Error()
 	}
 	}
 
 
-	diskMap := map[DiskIdentifier]*Disk{}
-
-	for _, result := range resPVCInfo {
-		cluster, err := result.GetCluster()
-		if err != nil {
-			cluster = env.GetClusterID()
-		}
-
-		volumeName, err := result.GetString("volumename")
-		if err != nil {
-			log.Debugf("ClusterDisks: pv claim data missing volumename")
-			continue
-		}
-		claimName, err := result.GetString("persistentvolumeclaim")
-		if err != nil {
-			log.Debugf("ClusterDisks: pv claim data missing persistentvolumeclaim")
-			continue
-		}
-		claimNamespace, err := result.GetNamespace()
-		if err != nil {
-			log.Debugf("ClusterDisks: pv claim data missing namespace")
-			continue
-		}
-
-		key := DiskIdentifier{cluster, volumeName}
-		if _, ok := diskMap[key]; !ok {
-			diskMap[key] = &Disk{
-				Cluster:   cluster,
-				Name:      volumeName,
-				Breakdown: &ClusterCostsBreakdown{},
-			}
-		}
-
-		diskMap[key].VolumeName = volumeName
-		diskMap[key].ClaimName = claimName
-		diskMap[key].ClaimNamespace = claimNamespace
-	}
+	diskMap := buildAssetsPVCMap(resPVCInfo)
 
 
 	pvCosts(diskMap, resolution, resActiveMins, resPVSize, resPVCost, resPVUsedAvg, resPVUsedMax, resPVCInfo, cp, opencost.NewClosedWindow(start, end))
 	pvCosts(diskMap, resolution, resActiveMins, resPVSize, resPVCost, resPVUsedAvg, resPVUsedMax, resPVCInfo, cp, opencost.NewClosedWindow(start, end))
 
 
@@ -557,7 +521,7 @@ func costTimesMinuteAndCount(activeDataMap map[NodeIdentifier]activeData, costMa
 			if c, ok := resourceCountMap[keyNon]; ok {
 			if c, ok := resourceCountMap[keyNon]; ok {
 				count = c
 				count = c
 			}
 			}
-			costMap[k] = cost * (minutes / 60) * count
+			costMap[k] = cost * (minutes / 60.0) * count
 		}
 		}
 	}
 	}
 }
 }
@@ -578,14 +542,14 @@ func ClusterNodes(dataSource source.OpenCostDataSource, cp models.Provider, star
 	optionalGrp := source.NewQueryGroup()
 	optionalGrp := source.NewQueryGroup()
 
 
 	// return errors if these fail
 	// return errors if these fail
-	resChNodeCPUHourlyCost := requiredGrp.With(dataSource.QueryNodeCPUHourlyCost(start, end))
+	resChNodeCPUHourlyCost := requiredGrp.With(dataSource.QueryNodeCPUPricePerHr(start, end))
 	resChNodeCPUCoresCapacity := requiredGrp.With(dataSource.QueryNodeCPUCoresCapacity(start, end))
 	resChNodeCPUCoresCapacity := requiredGrp.With(dataSource.QueryNodeCPUCoresCapacity(start, end))
 	resChNodeCPUCoresAllocatable := requiredGrp.With(dataSource.QueryNodeCPUCoresAllocatable(start, end))
 	resChNodeCPUCoresAllocatable := requiredGrp.With(dataSource.QueryNodeCPUCoresAllocatable(start, end))
-	resChNodeRAMHourlyCost := requiredGrp.With(dataSource.QueryNodeRAMHourlyCost(start, end))
+	resChNodeRAMHourlyCost := requiredGrp.With(dataSource.QueryNodeRAMPricePerGiBHr(start, end))
 	resChNodeRAMBytesCapacity := requiredGrp.With(dataSource.QueryNodeRAMBytesCapacity(start, end))
 	resChNodeRAMBytesCapacity := requiredGrp.With(dataSource.QueryNodeRAMBytesCapacity(start, end))
 	resChNodeRAMBytesAllocatable := requiredGrp.With(dataSource.QueryNodeRAMBytesAllocatable(start, end))
 	resChNodeRAMBytesAllocatable := requiredGrp.With(dataSource.QueryNodeRAMBytesAllocatable(start, end))
 	resChNodeGPUCount := requiredGrp.With(dataSource.QueryNodeGPUCount(start, end))
 	resChNodeGPUCount := requiredGrp.With(dataSource.QueryNodeGPUCount(start, end))
-	resChNodeGPUHourlyCost := requiredGrp.With(dataSource.QueryNodeGPUHourlyCost(start, end))
+	resChNodeGPUHourlyPrice := requiredGrp.With(dataSource.QueryNodeGPUPricePerHr(start, end))
 	resChActiveMins := requiredGrp.With(dataSource.QueryNodeActiveMinutes(start, end))
 	resChActiveMins := requiredGrp.With(dataSource.QueryNodeActiveMinutes(start, end))
 	resChIsSpot := requiredGrp.With(dataSource.QueryNodeIsSpot(start, end))
 	resChIsSpot := requiredGrp.With(dataSource.QueryNodeIsSpot(start, end))
 
 
@@ -599,7 +563,7 @@ func ClusterNodes(dataSource source.OpenCostDataSource, cp models.Provider, star
 	resNodeCPUCoresCapacity, _ := resChNodeCPUCoresCapacity.Await()
 	resNodeCPUCoresCapacity, _ := resChNodeCPUCoresCapacity.Await()
 	resNodeCPUCoresAllocatable, _ := resChNodeCPUCoresAllocatable.Await()
 	resNodeCPUCoresAllocatable, _ := resChNodeCPUCoresAllocatable.Await()
 	resNodeGPUCount, _ := resChNodeGPUCount.Await()
 	resNodeGPUCount, _ := resChNodeGPUCount.Await()
-	resNodeGPUHourlyCost, _ := resChNodeGPUHourlyCost.Await()
+	resNodeGPUHourlyPrice, _ := resChNodeGPUHourlyPrice.Await()
 	resNodeRAMHourlyCost, _ := resChNodeRAMHourlyCost.Await()
 	resNodeRAMHourlyCost, _ := resChNodeRAMHourlyCost.Await()
 	resNodeRAMBytesCapacity, _ := resChNodeRAMBytesCapacity.Await()
 	resNodeRAMBytesCapacity, _ := resChNodeRAMBytesCapacity.Await()
 	resNodeRAMBytesAllocatable, _ := resChNodeRAMBytesAllocatable.Await()
 	resNodeRAMBytesAllocatable, _ := resChNodeRAMBytesAllocatable.Await()
@@ -630,7 +594,7 @@ func ClusterNodes(dataSource source.OpenCostDataSource, cp models.Provider, star
 
 
 	cpuCostMap, clusterAndNameToType1 := buildCPUCostMap(resNodeCPUHourlyCost, cp, preemptibleMap)
 	cpuCostMap, clusterAndNameToType1 := buildCPUCostMap(resNodeCPUHourlyCost, cp, preemptibleMap)
 	ramCostMap, clusterAndNameToType2 := buildRAMCostMap(resNodeRAMHourlyCost, cp, preemptibleMap)
 	ramCostMap, clusterAndNameToType2 := buildRAMCostMap(resNodeRAMHourlyCost, cp, preemptibleMap)
-	gpuCostMap, clusterAndNameToType3 := buildGPUCostMap(resNodeGPUHourlyCost, gpuCountMap, cp, preemptibleMap)
+	gpuCostMap, clusterAndNameToType3 := buildGPUCostMap(resNodeGPUHourlyPrice, gpuCountMap, cp, preemptibleMap)
 
 
 	clusterAndNameToTypeIntermediate := mergeTypeMaps(clusterAndNameToType1, clusterAndNameToType2)
 	clusterAndNameToTypeIntermediate := mergeTypeMaps(clusterAndNameToType1, clusterAndNameToType2)
 	clusterAndNameToType := mergeTypeMaps(clusterAndNameToTypeIntermediate, clusterAndNameToType3)
 	clusterAndNameToType := mergeTypeMaps(clusterAndNameToTypeIntermediate, clusterAndNameToType3)

+ 45 - 2
pkg/costmodel/cluster_helpers.go

@@ -154,7 +154,7 @@ func buildRAMCostMap(
 			if err != nil {
 			if err != nil {
 				log.Warnf("ClusterNodes: error parsing custom RAM price: %s", customRAMStr)
 				log.Warnf("ClusterNodes: error parsing custom RAM price: %s", customRAMStr)
 			}
 			}
-			ramCost = customRAMCost / 1024 / 1024 / 1024
+			ramCost = customRAMCost
 
 
 		} else {
 		} else {
 
 
@@ -164,7 +164,8 @@ func buildRAMCostMap(
 
 
 		clusterAndNameToType[keyNon] = nodeType
 		clusterAndNameToType[keyNon] = nodeType
 
 
-		ramCostMap[key] = ramCost
+		// covert to price per byte/hr
+		ramCostMap[key] = ramCost / 1024.0 / 1024.0 / 1024.0
 	}
 	}
 
 
 	return ramCostMap, clusterAndNameToType
 	return ramCostMap, clusterAndNameToType
@@ -631,6 +632,48 @@ func buildPreemptibleMap(
 	return m
 	return m
 }
 }
 
 
+func buildAssetsPVCMap(resPVCInfo []*source.QueryResult) map[DiskIdentifier]*Disk {
+	diskMap := map[DiskIdentifier]*Disk{}
+
+	for _, result := range resPVCInfo {
+		cluster, err := result.GetCluster()
+		if err != nil {
+			cluster = env.GetClusterID()
+		}
+
+		volumeName, err := result.GetString("volumename")
+		if err != nil {
+			log.Debugf("ClusterDisks: pv claim data missing volumename")
+			continue
+		}
+		claimName, err := result.GetString("persistentvolumeclaim")
+		if err != nil {
+			log.Debugf("ClusterDisks: pv claim data missing persistentvolumeclaim")
+			continue
+		}
+		claimNamespace, err := result.GetNamespace()
+		if err != nil {
+			log.Debugf("ClusterDisks: pv claim data missing namespace")
+			continue
+		}
+
+		key := DiskIdentifier{cluster, volumeName}
+		if _, ok := diskMap[key]; !ok {
+			diskMap[key] = &Disk{
+				Cluster:   cluster,
+				Name:      volumeName,
+				Breakdown: &ClusterCostsBreakdown{},
+			}
+		}
+
+		diskMap[key].VolumeName = volumeName
+		diskMap[key].ClaimName = claimName
+		diskMap[key].ClaimNamespace = claimNamespace
+	}
+
+	return diskMap
+}
+
 func buildLabelsMap(
 func buildLabelsMap(
 	resLabels []*source.QueryResult,
 	resLabels []*source.QueryResult,
 ) map[nodeIdentifierNoProviderID]map[string]string {
 ) map[nodeIdentifierNoProviderID]map[string]string {

+ 1 - 1
pkg/costmodel/cluster_helpers_test.go

@@ -1057,7 +1057,7 @@ func TestAssetCustompricing(t *testing.T) {
 			customPricingMap: map[string]string{},
 			customPricingMap: map[string]string{},
 			expectedPricing: map[string]float64{
 			expectedPricing: map[string]float64{
 				"CPU":     0.5,
 				"CPU":     0.5,
-				"RAM":     0.5,
+				"RAM":     0.5 / 1024.0 / 1024.0 / 1024.0,
 				"GPU":     1.0,
 				"GPU":     1.0,
 				"Storage": 1.0,
 				"Storage": 1.0,
 			},
 			},

+ 3 - 3
pkg/costmodel/costmodel.go

@@ -643,9 +643,9 @@ func findDeletedNodeInfo(dataSource source.OpenCostDataSource, missingNodes map[
 
 
 		grp := source.NewQueryGroup()
 		grp := source.NewQueryGroup()
 
 
-		cpuCostResCh := grp.With(dataSource.QueryNodeCostPerCPUHr(start, end))
-		ramCostResCh := grp.With(dataSource.QueryNodeCostPerRAMGiBHr(start, end))
-		gpuCostResCh := grp.With(dataSource.QueryNodeCostPerGPUHr(start, end))
+		cpuCostResCh := grp.With(dataSource.QueryNodeCPUPricePerHr(start, end))
+		ramCostResCh := grp.With(dataSource.QueryNodeRAMPricePerGiBHr(start, end))
+		gpuCostResCh := grp.With(dataSource.QueryNodeGPUPricePerHr(start, end))
 
 
 		cpuCostRes, _ := cpuCostResCh.Await()
 		cpuCostRes, _ := cpuCostResCh.Await()
 		ramCostRes, _ := ramCostResCh.Await()
 		ramCostRes, _ := ramCostResCh.Await()