diff --git a/kubelet/datadog_checks/kubelet/prometheus.py b/kubelet/datadog_checks/kubelet/prometheus.py index 0f30fdac418b22..eb73205093d429 100644 --- a/kubelet/datadog_checks/kubelet/prometheus.py +++ b/kubelet/datadog_checks/kubelet/prometheus.py @@ -31,6 +31,7 @@ def __init__(self, *args, **kwargs): # and container__limit_ reads it to compute usage_pct self.fs_usage_bytes = {} self.mem_usage_bytes = {} + self.swap_usage_bytes = {} self.CADVISOR_METRIC_TRANSFORMERS = { 'container_cpu_usage_seconds_total': self.container_cpu_usage_seconds_total, @@ -53,8 +54,11 @@ def __init__(self, *args, **kwargs): 'container_fs_limit_bytes': self.container_fs_limit_bytes, 'container_memory_usage_bytes': self.container_memory_usage_bytes, 'container_memory_working_set_bytes': self.container_memory_working_set_bytes, + 'container_memory_cache': self.container_memory_cache, 'container_memory_rss': self.container_memory_rss, + 'container_memory_swap': self.container_memory_swap, 'container_spec_memory_limit_bytes': self.container_spec_memory_limit_bytes, + 'container_spec_memory_swap_limit_bytes': self.container_spec_memory_swap_limit_bytes, } def _create_cadvisor_prometheus_instance(self, instance): @@ -526,10 +530,21 @@ def container_memory_working_set_bytes(self, metric, scraper_config): metric_name = scraper_config['namespace'] + '.memory.working_set' self._process_container_metric('gauge', metric_name, metric, scraper_config) + def container_memory_cache(self, metric, scraper_config): + metric_name = scraper_config['namespace'] + '.memory.cache' + self._process_container_metric('gauge', metric_name, metric, scraper_config) + def container_memory_rss(self, metric, scraper_config): metric_name = scraper_config['namespace'] + '.memory.rss' self._process_container_metric('gauge', metric_name, metric, scraper_config) + def container_memory_swap(self, metric, scraper_config): + metric_name = scraper_config['namespace'] + '.memory.swap' + if metric.type not in METRIC_TYPES: + self.log.error("Metric type %s unsupported for metric %s" % (metric.type, metric.name)) + return + self._process_usage_metric(metric_name, metric, self.swap_usage_bytes, scraper_config) + def container_spec_memory_limit_bytes(self, metric, scraper_config): metric_name = scraper_config['namespace'] + '.memory.limits' pct_m_name = scraper_config['namespace'] + '.memory.usage_pct' @@ -537,3 +552,11 @@ def container_spec_memory_limit_bytes(self, metric, scraper_config): self.log.error("Metric type %s unsupported for metric %s" % (metric.type, metric.name)) return self._process_limit_metric(metric_name, metric, self.mem_usage_bytes, scraper_config, pct_m_name=pct_m_name) + + def container_spec_memory_swap_limit_bytes(self, metric, scraper_config): + metric_name = scraper_config['namespace'] + '.memory.sw_limit' + pct_m_name = scraper_config['namespace'] + '.memory.sw_in_use' + if metric.type not in METRIC_TYPES: + self.log.error("Metric type %s unsupported for metric %s" % (metric.type, metric.name)) + return + self._process_limit_metric(metric_name, metric, self.swap_usage_bytes, scraper_config, pct_m_name=pct_m_name) diff --git a/kubelet/metadata.csv b/kubelet/metadata.csv index 7107349ab82b12..fe2123c41df49a 100644 --- a/kubelet/metadata.csv +++ b/kubelet/metadata.csv @@ -21,11 +21,15 @@ kubernetes.io.read_bytes,gauge,,byte,,The amount of bytes read from the disk,0,k kubernetes.io.write_bytes,gauge,,byte,,The amount of bytes written to the disk,0,kubelet,k8_io_write_bytes kubernetes.memory.capacity,gauge,,byte,,The amount of memory (in bytes) in this machine,0,kubelet,k8s.mem.capacity kubernetes.memory.limits,gauge,,byte,,The limit of memory set,0,kubelet,k8s.mem.limits +kubernetes.memory.sw_limit,gauge,,byte,,The limit of swap space set,0,kubelet,k8s.mem.sw_limit kubernetes.memory.requests,gauge,,byte,,The requested memory,0,kubelet,k8s.mem.requests kubernetes.memory.usage,gauge,,byte,,Current memory usage in bytes including all memory regardless of when it was accessed,-1,kubelet,k8s.mem kubernetes.memory.working_set,gauge,,byte,,Current working set in bytes - this is what the OOM killer is watching for,-1,kubelet,k8s.mem.ws +kubernetes.memory.cache,gauge,,byte,,The amount of memory that is being used to cache data from disk (e.g. memory contents that can be associated precisely with a block on a block device),-1,kubelet,k8s.mem.cache kubernetes.memory.rss,gauge,,byte,,Size of RSS in bytes,-1,kubelet,k8s.mem.rss +kubernetes.memory.swap,gauge,,byte,,The amount of swap currently used by by processes in this cgroup,-1,kubelet,k8s.mem.swap kubernetes.memory.usage_pct,gauge,,fraction,,The percentage of memory used,-1,kubelet,k8s.mem.used_pct +kubernetes.memory.sw_in_use,gauge,,fraction,,The percentage of swap space used,-1,kubelet,k8s.mem.sw_in_use kubernetes.network.rx_bytes,gauge,,byte,second,The amount of bytes per second received,0,kubelet,k8s.net.rx kubernetes.network.rx_dropped,gauge,,packet,second,The amount of rx packets dropped per second,-1,kubelet,k8s.net.rx.drop kubernetes.network.rx_errors,gauge,,error,second,The amount of rx errors per second,-1,kubelet,k8s.net.rx.errors diff --git a/kubelet/tests/test_kubelet.py b/kubelet/tests/test_kubelet.py index 35c5c2d8ff9fbd..387e0e1be69e31 100644 --- a/kubelet/tests/test_kubelet.py +++ b/kubelet/tests/test_kubelet.py @@ -46,10 +46,14 @@ 'kubernetes.filesystem.usage_pct', 'kubernetes.memory.capacity', 'kubernetes.memory.limits', + 'kubernetes.memory.sw_limit', 'kubernetes.memory.requests', 'kubernetes.memory.usage', + 'kubernetes.memory.sw_in_use', 'kubernetes.memory.working_set', + 'kubernetes.memory.cache', 'kubernetes.memory.rss', + 'kubernetes.memory.swap', 'kubernetes.network.rx_bytes', 'kubernetes.network.tx_bytes', ]