gpt4 book ai didi

amazon-ecs - 如何确定每个日期的 ECS 服务的 Cloudwatch 日志流

转载 作者:行者123 更新时间:2023-12-05 02:54:46 29 4
gpt4 key购买 nike

我有一个运行任务的 ECS 集群服务,可以使用 AWS 控制台查看其 Cloudwatch 日志流。

如何为 awslogs-stream-prefix 设置日期,因为我想按日期识别日志流。

  "containerDefinitions": [
{
"dnsSearchDomains": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/my-task-definition",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}

最佳答案

遗憾的是,无法将 awslogs 驱动程序 配置为将 awslogs-stream-prefix 作为日期。

日志流是在创建任务时创建的,下面是根据 AWS[ 1 描述选项和建议的片段, 2 ] & Docker 文档 [ 1 ] 关于 awslogs 驱动程序。

The awslogs-stream-prefix option allows you to associate a log stream with the specified prefix, the container name, and the ID of the Amazon ECS task to which the container belongs. If you specify a prefix with this option, then the log stream takes the following format:

prefix-name/container-name/ecs-task-id

If you do not specify a prefix with this option, then the log stream is named after the container ID that is assigned by the Docker daemon on the container instance. Because it is difficult to trace logs back to the container that sent them with just the Docker container ID (which is only available on the container instance), we recommend that you specify a prefix with this option.

For Amazon ECS services, you could use the service name as the prefix, which would allow you to trace log streams to the service that the container belongs to, the name of the container that sent them, and the ID of the task to which the container belongs.

如果您只想知道 Steam 的创建日期,您可以在 AWS CloudWatch 控制台上查看日志,同时添加相同的列。

CloudWatch Console> Log Groups > Settings Icon on top right corner > check the Creation Time

关于amazon-ecs - 如何确定每个日期的 ECS 服务的 Cloudwatch 日志流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61630491/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com