Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify metrics processor #76

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions openshift_metrics/metrics_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ def merge_metrics(self, metric_name, metric_list):
namespace = metric["metric"]["namespace"]
node = metric["metric"].get("node")

gpu_type = None
gpu_resource = None
node_model = None

self.merged_data.setdefault(namespace, {})
self.merged_data[namespace].setdefault(pod, {"metrics": {}})

if metric_name == "gpu_request":
gpu_type = metric["metric"].get(
"label_nvidia_com_gpu_product", GPU_UNKNOWN_TYPE
)
gpu_resource = metric["metric"].get("resource")
node_model = metric["metric"].get("label_nvidia_com_gpu_machine")
gpu_type, gpu_resource, node_model = self._extract_gpu_info(
metric_name, metric
)

for value in metric["values"]:
epoch_time = value[0]
Expand All @@ -57,6 +50,22 @@ def merge_metrics(self, metric_name, metric_list):
"node"
] = node

@staticmethod
def _extract_gpu_info(metric_name: str, metric: Dict) -> tuple:
"""Extract GPU related info"""
gpu_type = None
gpu_resource = None
node_model = None

if metric_name == "gpu_request":
gpu_type = metric["metric"].get(
"label_nvidia_com_gpu_product", GPU_UNKNOWN_TYPE
)
gpu_resource = metric["metric"].get("resource")
node_model = metric["metric"].get("label_nvidia_com_gpu_machine")

return gpu_type, gpu_resource, node_model
naved001 marked this conversation as resolved.
Show resolved Hide resolved

def condense_metrics(self, metrics_to_check: List[str]) -> Dict:
"""
Checks if the value of metrics is the same, and removes redundant
Expand Down