|
|
@@ -34,6 +34,7 @@ const (
|
|
|
queryFmtPVActiveMins = `count(kube_persistentvolume_capacity_bytes{%s}) by (persistentvolume, %s)[%s:%s]`
|
|
|
queryFmtPVBytes = `avg(avg_over_time(kube_persistentvolume_capacity_bytes{%s}[%s])) by (persistentvolume, %s)`
|
|
|
queryFmtPVCostPerGiBHour = `avg(avg_over_time(pv_hourly_cost{%s}[%s])) by (volumename, %s)`
|
|
|
+ queryFmtPVMeta = `avg(avg_over_time(kubecost_pv_info{%s}[%s])) by (%s, persistentvolume, provider_id)`
|
|
|
queryFmtNetZoneGiB = `sum(increase(kubecost_pod_network_egress_bytes_total{internet="false", sameZone="false", sameRegion="true", %s}[%s])) by (pod_name, namespace, %s) / 1024 / 1024 / 1024`
|
|
|
queryFmtNetZoneCostPerGiB = `avg(avg_over_time(kubecost_network_zone_egress_cost{%s}[%s])) by (%s)`
|
|
|
queryFmtNetRegionGiB = `sum(increase(kubecost_pod_network_egress_bytes_total{internet="false", sameZone="false", sameRegion="false", %s}[%s])) by (pod_name, namespace, %s) / 1024 / 1024 / 1024`
|
|
|
@@ -454,6 +455,9 @@ func (cm *CostModel) computeAllocation(start, end time.Time, resolution time.Dur
|
|
|
queryPVCostPerGiBHour := fmt.Sprintf(queryFmtPVCostPerGiBHour, env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
|
|
|
resChPVCostPerGiBHour := ctx.QueryAtTime(queryPVCostPerGiBHour, end)
|
|
|
|
|
|
+ queryPVMeta := fmt.Sprintf(queryFmtPVMeta, env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
|
|
|
+ resChPVMeta := ctx.QueryAtTime(queryPVMeta, end)
|
|
|
+
|
|
|
queryNetTransferBytes := fmt.Sprintf(queryFmtNetTransferBytes, env.GetPromClusterFilter(), durStr, env.GetPromClusterLabel())
|
|
|
resChNetTransferBytes := ctx.QueryAtTime(queryNetTransferBytes, end)
|
|
|
|
|
|
@@ -545,6 +549,7 @@ func (cm *CostModel) computeAllocation(start, end time.Time, resolution time.Dur
|
|
|
resPVActiveMins, _ := resChPVActiveMins.Await()
|
|
|
resPVBytes, _ := resChPVBytes.Await()
|
|
|
resPVCostPerGiBHour, _ := resChPVCostPerGiBHour.Await()
|
|
|
+ resPVMeta, _ := resChPVMeta.Await()
|
|
|
|
|
|
resPVCInfo, _ := resChPVCInfo.Await()
|
|
|
resPVCBytesRequested, _ := resChPVCBytesRequested.Await()
|
|
|
@@ -650,7 +655,7 @@ func (cm *CostModel) computeAllocation(start, end time.Time, resolution time.Dur
|
|
|
// a PVC, we get time running there, so this is only inaccurate
|
|
|
// for short-lived, unmounted PVs.)
|
|
|
pvMap := map[pvKey]*pv{}
|
|
|
- buildPVMap(resolution, pvMap, resPVCostPerGiBHour, resPVActiveMins, window)
|
|
|
+ buildPVMap(resolution, pvMap, resPVCostPerGiBHour, resPVActiveMins, resPVMeta, window)
|
|
|
applyPVBytes(pvMap, resPVBytes)
|
|
|
|
|
|
// Build out the map of all PVCs with time running, bytes requested,
|