如果@timestamp 是前一个日期,Cloudwatch 查询将不起作用

问题描述 投票:0回答:0

我正在尝试使用 boto3 put_log_events 将一些旧日志(-10 天)推送到云监视。如果我为时间戳字段设置当前时间(以毫秒为单位),我就可以在日志流中运行 cloudwatch 查询。如果设置实际日志日期时间,云手表响应

“未找到此时间范围内的数据”

示例日志:

{"Namespace": "AWS/ECS", "Metric": "CPUUtilization", "Dimensions": {"Average": 0.08905141301220283, "Sum": 0.08905141301220283, "Unit": "Percent"}, "Timestamp": "2021-01-16T22:19:00+00:00"}

s = datetime.datetime(2021, 1, 15, 3, 17, tzinfo=tzutc()
time_data=int(round(s.timestamp() * 1000)) ## cloudwatch search does not work if this is set.

time_data = int(round(time.time() * 1000)) ## cloudwatch search works if this timestamp is set.

        msg=[ { "timestamp": time_data, 
                "message": message}
            ]

Cludwatch查询:

filter @logStream = 'daily-2021-01-27'
 | fields @timestamp, @message
 | filter Namespace = 'AWS/ECS' 

形成 AWS DOC:

-- timestamp -> (long)
The time the event occurred, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.

-- None of the log events in the batch can be older than 14 days or older than the retention period of the log group.

不确定我错过了什么。

(时间戳为过去 24 小时或更长时间的数据可能需要 从提交时间开始超过 48 小时可用 GetMetricStatistics.

) 这与这种行为有关吗?

python-3.x boto3 amazon-cloudwatch amazon-cloudwatchlogs aws-cloudwatch-log-insights
© www.soinside.com 2019 - 2024. All rights reserved.