AWS – How to get log group creation date using AWS CLI

Keywords: log group name, VPC Flow log, vpc flow log group

Do do so, change <your_log_group_name> for your log group name:

aws logs describe-log-groups --log-group-name-prefix "<your_log_group_name>" --query 'logGroups[?starts_with(logGroupName, <your_log_group_name>) == true].[logGroupName, creationTime]' --output text

Then you will receive a number like this that represent it’s timestamp: 1581405443909

To convert the timestamp, here are 3 options:

Bash in Linux

date -d @$((1581405443909 / 1000)) +"%Y-%m-%d %H:%M:%S"

Bash in MacOS

date -r $((1581405443909 / 1000)) +"%Y-%m-%d %H:%M:%S"

Python

import datetime

timestamp = 1581405443909 / 1000 # Convert milliseconds to seconds
creation_date = datetime.datetime.fromtimestamp(timestamp)
print(creation_date)

The result should be 2020-02-11 07:17:23 for all of them!

Deixe um comentĂ¡rio

O seu endereço de e-mail nĂ£o serĂ¡ publicado. Campos obrigatĂ³rios sĂ£o marcados com *