I have the following Log insights query that I'm using in CloudWatch to extract memory/cpu related stats:
stats avg(MemoryUtilized) as MemoryUsed, avg(CpuUtilized) as CpuUsed by TaskDefinitionFamily, TaskId, MemoryReserved, CpuReserved, Timestamp
| filter Type="Task" and TaskDefinitionFamily="auth-customer-TEST"
| sort Timestamp, TaskDefinition, TaskId desc
| limit 2
It outputs the following:
TaskDefinitionFamily | TaskId | MemoryReserved | CpuReserved | Timestamp | MemoryUsed | CpuUsed |
---|---|---|---|---|---|---|
my-service | 901abb3daadd49c6983f3c6431fd33b8 | 1024 | 256.0 | 1690275900000 | 322 | 1.6687 |
my-service | 9c831a65724e4b90ab2c4366954ac392 | 1024 | 256.0 | 1690275900000 | 295 | 1.1168 |
This is all good. However, I don't understand how I can order the columns.
I would like the MemoryUsed
and MemoryReserved
to be beside each other, the same for the CPU stats. Also, I'd like to remove the Timestamp
.
I thought I could query and sort by Timestamp
without specifying it in the first line, but I get different results if I do that.
Alternatively, is it possible to display the timestamp as a human readable date/time, or at least move it to the end of the table?
Could you try this query?
stats avg(MemoryUtilized) as MemoryUsed, MemoryReserved, avg(CpuUtilized) as CpuUsed by TaskDefinitionFamily, CpuReserved, TaskId, fromMillis(Timestamp) as DateTime
| filter Type="Task" and TaskDefinitionFamily="auth-customer-TEST"
| sort Timestamp, TaskDefinition, TaskId desc
| limit 2
Please try for more datetime functions here.