The important thing to remember is that logs and meta-data are dispersed across numerous "tables," requiring joins to retrieve the information you need. ContainerLog table (where logs are saved) and KubePodInventory (where container / pod metadata is maintained) are typically used.
We may create a query to get all logs from all pods, starting with the most recent ones, for the most basic part:
letstartTimestamp=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 |