def get_cgroup_container_metadata():
    """
    Reads docker/kubernetes metadata (container id, pod id) from /proc/self/cgroup

    The result is a nested dictionary with the detected IDs, e.g.

        {
            "container": {"id": "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63"},
            "pod": {"uid": "90d81341_92de_11e7_8cf2_507b9d4141fa"}
        }

    :return: a dictionary with the detected ids or {}
    """
    if not os.path.exists(CGROUP_PATH):
        return {}
    with open(CGROUP_PATH) as f:
        return parse_cgroups(f) or {}