def get_container_max_memory_usage_in_bytes(
        self, node_name: str, pod_name: str, container_name: str, duration: timedelta
    ) -> float:
        """
        Returns the maximal memory usage (in bytes) for the given container, in the time range between now and now - duration.r
        """

        # We use the container_memory_usage_bytes metric, with the following filters:
        # - node={node_name}:
        #   In order to filter on the given node.
        #
        # - pod={pod_name}:
        #   In order to filter on the given pod.
        #
        # - image!="":
        #   In order to ignore the metric of the pod in general, which sums the memory of each of its containers.
        #
        # - container!="POD":
        #   In order to ignore paused containers. For more information, please see:
        #   https://stackoverflow.com/questions/68683403/what-is-the-container-pod-label-in-prometheus-and-why-do-most-examples-exclude
        #
        # - container={container_name}:
        #   In order to filter on the given container name.
        #
        # - id=~"/kubepods/.*":
        #   In order to filter multiple ids that are returned for the same container.
        #   In my minikube, for example, 2 time series are returned for each container, one with id=/docker/* and one with id=/kubepods/*.
        #   However, an id of the form /kubepods/* always exists. Also, the following prefixes are always mutual exclusive:
        #       /kubepods/burstable/*
        #       /kubepods/besteffort/*
        #       /kubepods/guaranteed/*
        #   Therefore, there will always be exactly one id of the form /kubepods/* prefix for each container.
        #   See https://stackoverflow.com/questions/49035724/how-do-i-resolve-kubepods-besteffort-poduuid-to-a-pod-name for more information.

        return self._get_max_value_in_first_series_of_query(
            f'container_memory_usage_bytes{{node="{node_name}", pod="{pod_name}", image!="", '
            f'container!="POD", container="{container_name}", id=~"/kubepods/.*"}}',
            duration,
        )

        Returns the maximal memory usage (in bytes) for the given container, in the time range between now and now - duration.r
        
src/robusta/integrations/resource_analysis/memory_analyzer.py