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

问题描述

我正在尝试使用 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' 

Form 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。

) 这与此行为有关吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)