Sitemap

Azure AKS — Export Container Logs to Storage Account

2 min readFeb 7, 2022

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

apiVersion: v1

kind: Pod

metadata:

name: ubuntu

spec:

containers:

- name: ubuntu

image: ubuntu:latest

# 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

Press enter or click to view image in full size

4. For Destination, please use a Storage Account in your subscription.

Press enter or click to view image in full size

5. After the Export Rule created, you will find the correspondent Containers in your Storage Account

Press enter or click to view image in full size

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

Press enter or click to view image in full size

8. By Downloading and opening this file the output of your Containers will be found in the content.

Press enter or click to view image in full size

--

--

No responses yet