简体   繁体   English

从 aws-cli 将日志写入 cloudwatch

[英]writing logs to cloudwatch from the aws-cli

i'm trying to write a log to cloudwatch (just to understand how it works)我正在尝试将日志写入 cloudwatch(只是为了了解它是如何工作的)

so from the aws-cli (already configured) i'm issuing this command所以从 aws-cli (已经配置)我发出这个命令

aws logs put-log-events --log-group-name testgroup --log-stream-name teststream1 --log-events timestamp=1587488538,message=hello

on cloudwatch the group-name and the stream-log already exist anthe the names are correct在 cloudwatch 上,组名和流日志已经存在,并且名称是正确的

the output of the command is the following命令的output如下

{ "rejectedLogEventsInfo": { "tooOldLogEventEndIndex": 1 } }

the user i'm using has the "AdministratorAccess" policy attached (and to be sure i've added "CloudWatchFullAccess" policy as well)我正在使用的用户附加了“AdministratorAccess”策略(并确保我也添加了“CloudWatchFullAccess”策略)

You need to convert your timestamp to milliseconds version (multiply with 1000 in your case)您需要将时间戳转换为毫秒版本(在您的情况下乘以 1000)

aws logs put-log-events --log-group-name testgroup --log-stream-name teststream1 --log-events timestamp=1587488538000,message=hello

please check examples请检查示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM