title: How to compute kubernetes memory usage with Grafana
body: <p>I have  setup a new grafana board monitoring the memory usage of my Kubernetes nodes. I have build to metrics which I can monitor separately.</p>
  <p>Total Memory for all nodes:</p>
  <pre><code>sum (machine_memory_bytes{kubernetes_io_hostname=~&quot;^$Node$&quot;}) by (kubernetes_io_hostname)
  </code></pre>
  <p>And the memory usage by nodes:</p>
  <pre><code>sum (container_memory_working_set_bytes{id=&quot;/&quot;,kubernetes_io_hostname=~&quot;^$Node$&quot;}) by (kubernetes_io_hostname)
  </code></pre>
  <p>Both metrics show the values I expect. But what I try to archive is the usage in percent.</p>
  <pre><code> metric-1 / metric-2 * 100
  </code></pre>
  <p>Something like:</p>
  <pre><code>sum (container_memory_working_set_bytes{id=&quot;/&quot;,kubernetes_io_hostname=~&quot;^$Node$&quot;})  
  / 
  sum (machine_memory_bytes{kubernetes_io_hostname=~&quot;^$Node$&quot;}) 
  * 100
  by (kubernetes_io_hostname)
  </code></pre>
  <p>But this did not work. Because the metric is now invalid. How can I achieve this?</p>