Merge "Aggregate by label when querying instance cpu usage in prometheus"

This commit is contained in:
Zuul
2025-06-19 14:46:07 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 8 deletions

View File

@@ -342,10 +342,12 @@ class PrometheusHelper(base.DataSourceBase):
)
vcpus = 1
query_args = (
"clamp_max((%s by (instance)(rate(%s{%s='%s'}[%ss]))/10e+8) "
"*(100/%s), 100)" %
(aggregate, meter, uuid_label_key, instance_label, period,
vcpus)
"clamp_max((%(agg)s by (%(label)s)"
"(rate(%(meter)s{%(label)s='%(label_value)s'}[%(period)ss]))"
"/10e+8) *(100/%(vcpus)s), 100)"
% {'label': uuid_label_key, 'label_value': instance_label,
'agg': aggregate, 'meter': meter, 'period': period,
'vcpus': vcpus}
)
else:
raise exception.InvalidParameter(