Srinivas Bandaru
Srinivas Bandaru

Reputation: 321

Azure AKS application logs for the application running in Pod from Azure Portal?

We can access pod related logs from Log Analytics Workspace but there are no app logs (similar to what we see in kubectl get events).

I was referring the Azure documentation but I am still unable to access Application Pod logs from Azure Portal

Upvotes: 3

Views: 20205

Answers (1)

In the portal part you have to go to the Kubernetes Services --> Monitoring --> Logs.

In this part, you have to query what you want. Similar to kubectl but in kusto query language.

Then you can try this query:

let startTimestamp = ago(1h);
KubePodInventory
| where TimeGenerated > startTimestamp
| project ContainerID, PodName=Name
| distinct ContainerID, PodName
| join
(
    ContainerLog
    | where TimeGenerated > startTimestamp
)
on ContainerID
// at this point before the next pipe, columns from both tables are available to be "projected". Due to both 
// tables having a "Name" column, we assign an alias as PodName to one column which we actually want
| project TimeGenerated, PodName, LogEntry, LogEntrySource
| order by TimeGenerated desc

I found this and tried it and it works. More information on this page if you want to take a look.

https://blog.coffeeapplied.com/using-azure-monitor-logs-with-azure-kubernetes-service-aks-c0b0625295d1

Upvotes: 9

Related Questions