How can I search Kubernetes logs when pods restart before I can investigate their logs?
A container restarts, your checkout service recovers, and you still need to find the logs from before the failure. In SigNoz Cloud, you can search that history by application service, namespace, pod, and container when the logs were collected using Kubernetes pod log collection and remain within the workspace’s configured retention period.
The investigation starts with the service and failure window. From there, narrow the results to the pod and container involved, using the pod UID when you need to distinguish a failed pod from a replacement.
Collect Kubernetes logs before the failure
Set up the SigNoz K8s Infra collection agent in the cluster running your applications and configure it to send telemetry to your SigNoz Cloud workspace. Follow the steps for your chosen method, using your workspace’s ingestion endpoint and key, then confirm that application logs appear in the Logs Explorer.
While the collection agents run in your Kubernetes cluster, SigNoz Cloud ingests the log records and routes them to your workspace. In case of any problems with log collection, check the deployed collection rules for namespace, pod, and container exclusions.
Once logs have reached SigNoz Cloud, you search the stored records rather than asking the failed container to serve them. Kubernetes’ kubectl logs --previous is useful for immediate access to a previous container instance, but it is not a durable archive. By default, the kubelet keeps one terminated container with its logs, and pod eviction removes the corresponding containers and logs.
Check the fields that identify your service
Open a log from the application and inspect its resource fields. For the workflow below, use the available fields corresponding to these identities:
| Resource Field | What it identifies |
|---|---|
service.name | The application service, such as checkout |
k8s.cluster.name | The cluster running the workload |
k8s.namespace.name | The workload’s namespace |
k8s.pod.name | The pod name |
k8s.pod.uid | One specific pod instance |
k8s.container.name | The container within the pod |
OpenTelemetry defines the Kubernetes resource attributes, and SigNoz Cloud documents resource attributes for logs. Inspect an ingested log record to confirm the fields supplied by your collection setup.
Here, service means the application identity in service.name. SigNoz Cloud supports setting resource attributes in application SDKs or Collector processors. Apply the mapping to the relevant workload’s logs so different applications retain their own service identities.
A distinct identity for each resource is a foundation of observability. It helps you connect an event to the service, pod, or container that produced it, so you can investigate the right source.
The screenshots below follow an example checkout service through a container restart and a pod replacement. Its logs were exported directly through the OpenTelemetry SDK with Kubernetes resource attributes. The example illustrates searching records already stored in SigNoz Cloud; the K8s Infra agent described above provides the container log collection path for your workloads.

Search by service, namespace, pod, and container
In Logs Explorer, select a time range covering the failure and restart. Begin with the cluster, namespace, and application service to see the incident across its pods.
In this example, the checkout application runs in the signoz-log-restart-demo namespace of docker-desktop. These values identify the service in the screenshots:
| Filter | Example value |
|---|---|
k8s.cluster.name | docker-desktop |
k8s.namespace.name | signoz-log-restart-demo |
service.name | checkout |
Combine the applicable conditions with AND and run the query. Starting at service scope helps you find records from the affected workload even when you do not yet know which pod failed. Use the exact fields and values visible in your logs.
The application recorded a marker before and after each lifecycle change, plus an error when it exited with code 1. The query shown below includes body CONTAINS 'a04982e4965b' to isolate these five records from the application's heartbeat logs. The results are newest first: the replacement pod's marker appears above the old pod's records.

Once you identify the affected pod, add its k8s.pod.name and k8s.container.name. In this example, narrow the logs to pod checkout-log-demo-85cdfb7b4f-zpggt and container app. Keep the time range covering the period before the restart so you can inspect the failure records alongside the later startup messages.
Distinguish the failed instance from its replacement
A container restart within the same pod retains the pod identity, whereas a replacement pod is a different instance, although the pod name may be reused. Filter on k8s.pod.uid when you need the failed pod’s records. To distinguish container executions within that pod, use the failure time and, when collected, a container ID or k8s.container.restart_count.
In this example, Kubernetes restarted the container after the controlled exit. The pod UID stayed the same, while the application's boot_id changed and its start_number increased from 1 to 2. These are custom application fields used to distinguish process executions in the example, rather than built-in Kubernetes attributes.
The pod was subsequently deleted, and the Deployment created a replacement with a new UID. Filtering on the old pod's UID still returned its four marker and error records after deletion, excluding the replacement pod's marker.

After locating the error, open the log details and inspect the Context tab for surrounding messages. To compare the failure with CPU and memory history, continue with the guide to investigating a crashing pod using logs and historical metrics.
When the earlier logs do not appear
First widen the time range and remove the pod, container, or service filter to check whether the records arrived with different attributes. If the workload’s logs are still missing, check its collection rules and the Collector’s export status using the installation verification steps.
Check the log retention shown under Settings → Workspace in SigNoz Cloud. Note that increasing retention does not restore expired records.
To investigate your own Kubernetes workloads, create a SigNoz Cloud workspace and follow the K8s Infra installation guide.