Azure AKS — Export Container Logs to Storage Account
HowTo — Export Container Logs to Storage Account
1. Create a test Container for this task with the following manifest. It will output a message to stdout once at 30s by default, this can also be seen with kubectl logs ubuntu
- name: ubuntu
# Just spin & wait forever
command: [ “/bin/bash”, “-c”, “ — “ ]
args: [ “while true; echo LogsTo_Storage_Account_Example; do sleep 30; done;” ]
2. By selecting Data Export Tab from the Log Analytics Workspace connected to your AKS Cluster you can create a New Export Rule
3. As the source for the Export Rule in our case you can use Container Logs table
4. For Destination, please use a Storage Account in your subscription.
5. After the Export Rule created, you will find the correspondent Containers in your Storage Account
6. By accessing the am-containerlog Container in the Storage Account will find a Folder Structure containing the complete Path and complete date, month, time and 5 min parts
7. The filename for every 5 min time part is called PTSM.json
8. By Downloading and opening this file the output of your Containers will be found in the content.