[put-log-events
期望JSON文件需要由[
和]
换行
例如
# aws logs put-log-events --log-group-name my-logs --log-stream-name 20150601 --log-events file://events
[
{
"timestamp": long,
"message": "string"
}
...
]
但是,我的JSON文件是多行格式,例如
{"timestamp": xxx, "message": "xxx"}
{"timestamp": yyy, "message": "yyy"}
是否可以在不编写自己的程序的情况下上传?
[1] https://docs.aws.amazon.com/cli/latest/reference/logs/put-log-events.html#examples
如果要将这些行保留为单个事件,则可以将这些行强制转换为字符串,将其与\n
合并并以这种方式发送。
由于行本身看起来像是自给自足的json,所以将它们作为事件数组发送(因此[...]
)可能并没有那么糟糕,因为它们将进入同一日志组,并且很容易成批查找。