from typing import Dict
from typing import Tuple


def get_metric_name_value(metric: Dict, field: str) -> Tuple:
    """获取metrics名称, 值"""
    metric_type = metric["type"]
    # CPU/MEM 等系统类型
    if metric_type == "Resource":
        name = metric["resource"]["name"]
        metric_value = metric["resource"][field]["averageUtilization"]
    else:
        # Pod等自定义类型
        name = metric[metric_type.lower()]["metric"]["name"]
        metric_value = metric[metric_type.lower()][field].get("averageValue")
    return name, metric_value