来自 Azure 门户的 Pod 中运行的应用程序的 Azure AKS 应用程序日志?

Sri*_*aru 3 azure-log-analytics azure-aks

我们可以从 Log Analytics Workspace 访问 Pod 相关日志,但没有应用程序日志(与我们在 中看到的类似kubectl get events)。

我指的是 Azure 文档,但我仍然无法从 Azure 门户访问应用程序 Pod 日志

小智 9

在门户部分,您必须转到 Kubernetes 服务 --> 监控 --> 日志。

在这一部分,你必须查询你想要什么。与 kubectl 类似,但采用 kusto 查询语言。

然后你可以尝试这个查询:

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
Run Code Online (Sandbox Code Playgroud)

我发现了这个并尝试了一下,它有效。如果您想查看更多信息,请参阅此页面。

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