How to use prometheus query language to query k8s node memory usage

You will need to port-forward you prometheus to you local 8080 port if you dont have a LB or ingress setup. I have prometheus server running on port 80 in kube-system namespace.

kubectl port-forward svc/prometheus-server 8080:80 -n kube-system

Visit http://localhost:9090 and then click graph tab. paste the following code into the expression. and click execute you will have the graph shows below

((sum(node_memory_MemTotal_bytes) - sum(node_memory_MemFree_bytes) - sum(node_memory_Buffers_bytes) - sum(node_memory_Cached_bytes)) / sum(node_memory_MemTotal_bytes)) * 100