<p>I am trying to interpret the metrics fetched using Telegraf with the Kubernetes plugins on the k3s cluster. I see the results are reporting the CPU in terms of nanoseconds and memory and disk in terms of bytes. More importantly, I like to understand how the CPU usage shows in ns can be converted into <code>%</code>?<br />
Below is one such example capture:</p>
<pre><code>kubernetes_pod_container,container_name=telegraf-ds,host=ah-ifc2,namespace=default,node_name=ah-ifc2,pod_name=telegraf-ds-dxdhz, rootfs_available_bytes=73470144512i,logsfs_available_bytes=0i,logsfs_capacity_bytes=0i,cpu_usage_nanocores=243143i,memory_usage_bytes=0i,memory_working_set_bytes=25997312i,memory_major_page_faults=0i,rootfs_used_bytes=95850790i,logsfs_used_bytes=4096i,cpu_usage_core_nanoseconds=4301919390i,memory_rss_bytes=0i,memory_page_faults=0i,rootfs_capacity_bytes=196569534464i 1616950920000000000
</code></pre>
<p>Also, how any visualization tool such as Chronograf/Grafana converts these raw data in a more actionable format such as <code>cpu%, memory/disk utilization%</code>?</p>
<p>Thanks and any advice will help.</p>

Containers-Intrest
<p>If you have a running total of the number of (nano)seconds, you can look at the derivative to figure out percentages.</p>
<p>Example:</p>
<ul>
<li>At time <code>00:00:00</code> the cpu usage counter was at <code>1,000,000,000ns</code></li>
<li>At time <code>00:00:10</code> the cpu usage counter was at <code>3,000,000,000ns</code></li>
</ul>
<p>From this information we can conclude that during the 10 seconds between <code>00:00:00</code> and <code>00:00:10</code> the process used the cpu for <code>3,000,000,00 - 1,000,000,000 = 2,000,000,000</code> nanoseconds.</p>
<p>In other words, it used the cpu for 2 seconds out of 10, giving us a cpu usage of 20%.</p>
