How to retain logs after pod deletion?

Ritika Laddha 140 Reputation points
2023-10-31T14:23:28.0366667+00:00

Is there any way to add configuration to my AKS cluster to keep log data from Kubernetes pods that have been deleted. For example, If there were 3 pods running, after sometime or maybe a day; there are only 2 pods. I would want to see logs of that terminated/ deleted pod.

Is there a way to configure some logging solution in AKS to store the logs of deleted pods for a period of time? Or If pod is going to be terminated it should save logs somewhere before termination.

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,196 questions
0 comments No comments
{count} votes

Accepted answer
  1. KarishmaTiwari-MSFT 20,302 Reputation points Microsoft Employee
    2023-10-31T18:43:32.6766667+00:00

    @Ritika Laddha Thanks for posting your query on Microsoft Q&A.

    You can use Azure Monitor to collect logs from your AKS cluster and store them in a Log Analytics workspace. Azure Monitor provides a centralized solution for collecting, analyzing, and acting on telemetry from your cloud and on-premises environments.

    To retain logs of deleted pods, you can configure log retention for the Log Analytics workspace. This will allow you to store logs for a specified period, even if the pods that generated the logs have been deleted.
    https://learn.microsoft.com/en-us/azure/aks/monitor-aks

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.