<p>Is it possible to obtain Kubernetes logs for a dedicated time range?</p>
<p>All I can do right now is to make a dump of about the last-hour log for the single pod using <code>kubectl logs &gt; dump.log</code> cmd.</p>
<p>But for debugging reasons, it's necessary to obtain the logs for the last week. I was unable to find any abilities to do this in Kubernetes logs.</p>
<p>The only thought is to attach some external service like Kibana for the logs collection, but maybe built-in Kubernetes remedies allow to do this?</p>
<p>Thank you.</p>

<p><strong>AWK</strong> is an awesome tool in Unix/Linux systems for these types of logical operations</p>
<p>So, to display logs in between two-time ranges (ex: 10 AM to 11 AM):</p>
<ol>
<li><p>Using <code>--since-time</code> and <code>awk</code></p>
<p><code>kubectl logs pod_name --since-time=2022-04-30T10:00:00Z | awk '$0 &lt; &quot;2022-04-30 11:00:00&quot;'</code></p>
</li>
<li><p>Using only <code>awk</code></p>
<p><code>kubectl logs pod_name | awk '$0 &gt; &quot;2022-04-30 10:00:00&quot;' | awk '$0 &lt; &quot;2022-04-30 11:00:00&quot;'</code></p>
</li>
</ol>
<p>Note: Please format date_time using in awk command based on the logs output.</p>
