<p>I have a Kubernetes cluster and I need to collect the various pod and node event timestamps.</p>
<p>I do that by building a go service that communicates with my Kubernetes cluster via client-go library. The timestamp I get for the subscribed pod and node object shows time only till seconds precision.</p>
<p>Is there a way one can get time in milliseconds precision level? I found a <a href="https://github.com/kubernetes/kubernetes/issues/81026" rel="nofollow noreferrer">similar issue raised</a> but there is no resolution of that.</p>
<p>Could someone help me in this?</p>

Shresthi Garg
<p>Welcome to the community @shresthi-garg</p>
<p>First of all, as you correctly found, it's not possible to get precise timestamps from kubernetes components themselves with milliseconds precision. And <a href="https://github.com/kubernetes/kubernetes/issues/81026#issuecomment-832301082" rel="nofollow noreferrer">this github issue</a> is closed for now.</p>
<p>However it's still possible to find some exact timings about containers and other events. Below is an example related to a container.</p>
<p><strong>Option 1</strong> - kubelet by default writes significant amount of logs to syslog. It's possible to view them with using <code>journalctl</code> (note! this approach works on <code>systemd</code> systems. For other systems please refer to <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-cluster/#looking-at-logs" rel="nofollow noreferrer">official kubenetes documentation</a>). Example of the command:</p>
<p><code>journalctl -u kubelet -o short-precise</code></p>
<p>-u - filter by unit</p>
<p>-o - output options</p>
<p>Line from output which we're looking for will be:</p>
<pre><code>May 18 21:00:30.221950 control-plane kubelet[8576]: I0518 21:00:30.221566    8576 scope.go:111] &quot;RemoveContainer&quot; containerID=&quot;d7d0403807684ddd4d2597d32b90b1e27d31f082d22cededde26f6da8281cd92&quot;
</code></pre>
<p><strong>Option 2</strong> - get this information from containerisation engine. In the example below I used Docker for this.
I run this command:</p>
<p><code>docker inspect container_id/container_name</code></p>
<p>Output will be like:</p>
<pre><code>{
        &quot;Id&quot;: &quot;d7d0403807684ddd4d2597d32b90b1e27d31f082d22cededde26f6da8281cd92&quot;,
        &quot;Created&quot;: &quot;2021-05-18T21:00:07.388569335Z&quot;,
        &quot;Path&quot;: &quot;/docker-entrypoint.sh&quot;,
        &quot;Args&quot;: [
            &quot;nginx&quot;,
            &quot;-g&quot;,
            &quot;daemon off;&quot;
        ],
        &quot;State&quot;: {
            &quot;Status&quot;: &quot;running&quot;,
            &quot;Running&quot;: true,
            &quot;Paused&quot;: false,
            &quot;Restarting&quot;: false,
            &quot;OOMKilled&quot;: false,
            &quot;Dead&quot;: false,
            &quot;Pid&quot;: 8478,
            &quot;ExitCode&quot;: 0,
            &quot;Error&quot;: &quot;&quot;,
            &quot;StartedAt&quot;: &quot;2021-05-18T21:00:07.593216613Z&quot;,
            &quot;FinishedAt&quot;: &quot;0001-01-01T00:00:00Z&quot;
        }
</code></pre>
