Skip to content

Commit f9acea5

Browse files
committed
feat(disable-power-models): Update Other and Total Energy Metric calculations
If DisablePowerModels is enabled, any metrics with source "trained_power_model" that are used in Other and Total Energy Calculations (ex. kepler_node_other_joules_total, kepler_process_other_joules_total, kepler_container_other_joules_total, kepler_container_joules_total, kepler_process_joules_total) are removed from the calculation (by replacing the metric value with 0). Negative values will be replaced with 0. If all metrics used for Other and Total Energy Calculations are from source "trained_power_model", then the Other and Total Energy Calculations will export 0 (they will not be removed from prometheus). Signed-off-by: Kaiyi Liu <[email protected]>
1 parent 7019cce commit f9acea5

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

pkg/metrics/metricfactory/metric_factory.go

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func EnergyMetricsPromDesc(context string) (descriptions map[string]*prometheus.
4646
} else if components.IsSystemCollectionSupported() && strings.Contains(allComponents, name) {
4747
// TODO: need to update condition when we have more type of energy metric such as network, disk.
4848
source = components.GetSourceName()
49+
} else if strings.Contains(name, config.OTHER) {
50+
source = ""
4951
}
5052
if !config.DisablePowerModels() || source != modeltypes.TrainedPowerModelSource {
5153
descriptions[name] = energyMetricsPromDesc(context, name, source)

pkg/model/node_component_energy.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,20 @@ func UpdateNodeComponentIdleEnergy(nodeMetrics *stats.NodeStats) {
109109

110110
func addEnergy(nodeMetrics *stats.NodeStats, metrics []string, isIdle bool) {
111111
for socket, power := range GetNodeComponentPowers(nodeMetrics, isIdle) {
112+
corePower := power.Core
113+
dramPower := power.DRAM
114+
uncorePower := power.Uncore
115+
pkgPower := power.Pkg
116+
if config.DisablePowerModels() {
117+
corePower = 0
118+
dramPower = 0
119+
uncorePower = 0
120+
pkgPower = 0
121+
}
112122
strID := fmt.Sprintf("%d", socket)
113-
nodeMetrics.EnergyUsage[metrics[0]].SetDeltaStat(strID, power.Core*config.SamplePeriodSec())
114-
nodeMetrics.EnergyUsage[metrics[1]].SetDeltaStat(strID, power.DRAM*config.SamplePeriodSec())
115-
nodeMetrics.EnergyUsage[metrics[2]].SetDeltaStat(strID, power.Uncore*config.SamplePeriodSec())
116-
nodeMetrics.EnergyUsage[metrics[3]].SetDeltaStat(strID, power.Pkg*config.SamplePeriodSec())
123+
nodeMetrics.EnergyUsage[metrics[0]].SetDeltaStat(strID, corePower*config.SamplePeriodSec())
124+
nodeMetrics.EnergyUsage[metrics[1]].SetDeltaStat(strID, dramPower*config.SamplePeriodSec())
125+
nodeMetrics.EnergyUsage[metrics[2]].SetDeltaStat(strID, uncorePower*config.SamplePeriodSec())
126+
nodeMetrics.EnergyUsage[metrics[3]].SetDeltaStat(strID, pkgPower*config.SamplePeriodSec())
117127
}
118128
}

pkg/model/node_platform_energy.go

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ func GetNodePlatformPower(nodeMetrics *stats.NodeStats, isIdlePower bool) (platf
9595
func UpdateNodePlatformEnergy(nodeMetrics *stats.NodeStats) {
9696
platformPower := GetNodePlatformPower(nodeMetrics, absPower)
9797
for sourceID, power := range platformPower {
98+
if config.DisablePowerModels() {
99+
power = 0
100+
}
98101
nodeMetrics.EnergyUsage[config.AbsEnergyInPlatform].SetDeltaStat(sourceID, power*config.SamplePeriodSec())
99102
}
100103
}
@@ -103,6 +106,9 @@ func UpdateNodePlatformEnergy(nodeMetrics *stats.NodeStats) {
103106
func UpdateNodePlatformIdleEnergy(nodeMetrics *stats.NodeStats) {
104107
platformPower := GetNodePlatformPower(nodeMetrics, idlePower)
105108
for sourceID, power := range platformPower {
109+
if config.DisablePowerModels() {
110+
power = 0
111+
}
106112
nodeMetrics.EnergyUsage[config.IdleEnergyInPlatform].SetDeltaStat(sourceID, power*config.SamplePeriodSec())
107113
}
108114
}

0 commit comments

Comments
 (0)