简体   繁体   English

是否可以重命名AWS CloudWatch日志组?

[英]Is it possible to rename an AWS CloudWatch Log Group?

I have created an AWS CloudWatch log group with a name which was not very future proof. 我创建了一个AWS CloudWatch日志组,其名称不是未来的证据。 Is it possible to rename such a log group? 是否可以重命名这样的日志组? I could find no option to do this via the CloudWatch console. 我无法通过CloudWatch控制台找到这样做的选项。

I guess an alternative would be to export the content of the log group, create a new log group with the desired name, and then re-consume the exported logs to the new log group. 我想另一种方法是导出日志组的内容,创建一个具有所需名称的新日志组,然后将导出的日志重新使用到新的日志组。 I would prefer to avoid this approach though, as (apart from being tedious) this would reset the ingestionTime of all the log events in the log group. 我宁愿避免这种做法虽然,因为(除了是繁琐的),这将重置ingestionTime日志组中的所有日志事件。

It does not seem to be possible at the current time. 目前似乎不可能。 The AWS CLI only lists the following log-group -related actions at this time: AWS CLI目前仅列出以下与log-group相关的操作:

  • create-log-group 创建日志组
  • delete-log-group 删除日志组
  • describe-log-groups 描述了日志,群
  • list-tags-log-group 列表标签日志组
  • tag-log-group 标签日志组
  • untag-log-group UNTAG日志组

My solution, since the log-group was only recently created and all the original log files were still on the EC2 instance, was to: 我的解决方案,因为日志组最近才创建,并且所有原始日志文件仍在EC2实例上,所以:

  1. stop the CloudWatch Logs agent on the EC2 instance with $ /etc/init.d/awslogs stop . 使用$ /etc/init.d/awslogs stop EC2实例上的CloudWatch Logs代理。
  2. ensure the application was not currently running/logging on the EC2 instance 确保应用程序当前未运行/登录EC2实例
  3. delete the existing log-group on CloudWatch 删除CloudWatch上的现有日志组
  4. move the existing log files out of the expected directory on the EC2 instance 将现有日志文件移出EC2实例上的预期目录
  5. edit the file /var/awslogs/etc/awslogs.conf on the EC2 instance to specify the desired log group name instead of the previous one. 编辑EC2实例上的文件/var/awslogs/etc/awslogs.conf以指定所需的日志组名称而不是前一个名称。
  6. start the CloudWatch Logs agent on the EC2 instance with $ /etc/init.d/awslogs start . 使用$ /etc/init.d/awslogs start EC2实例上的CloudWatch Logs代理。
  7. move each log file back into the expected directory on the EC2 instance, one at a time, from the earliest to the latest (in terms of file modification time), so the log agent will process all of them (and not just ignore files with non-latest modification time) and send them to the new log-group. 将每个日志文件从最早到最晚(就文件修改时间而言)一次一个地移回EC2实例上的预期目录,因此日志代理将处理所有这些(而不仅仅是忽略文件非最新修改时间)并将它们发送到新的日志组。
  8. restart the application on the EC2 instance 在EC2实例上重启应用程序

Quite the tedious procedure, especially with having to manually move the log files, one at a time, in the correct order. 相当繁琐的程序,尤其是必须以正确的顺序一次一个地手动移动日志文件。 Would be neat if there was functionality in the future to rename a log group. 如果将来有功能重命名日志组,那将会很整洁。

A "solution" ... 一个办法” ...

Create the new log group. 创建新的日志组。 Have the streams write to this log group. 让流写入此日志组。 Using aws cli get the events for each of the streams for the old log group and then put them to the new group. 使用aws cli获取旧日志组的每个流的事件,然后将它们放入新组。

I've got about 2,000 streams I'm about to do this too. 我也有大约2000个流我也要这样做。 We restructured are group names. 我们重组的是团体名称。

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

相关问题 AWS CloudWatch - 日志组不存在 - AWS CloudWatch - Log group does not exist 将 AWS CloudWatch 日志组流式传输到多个 AWS Elasticsearch 服务 - Stream AWS CloudWatch Log Group to Multiple AWS Elasticsearch Services AWS Cloudwatch 日志 - 是否可以从中导出现有日志数据? - AWS Cloudwatch Log - Is it possible to export existing log data from it? 使用 EKS 中的流利位在 AWS cloudwatch 中自动创建日志组 - Automatic log group creation in AWS cloudwatch using fluent bit in EKS 使用 boto3 查询 AWS Cloudwatch 日志组订阅 - Querying AWS Cloudwatch Log Group Subscriptions Using boto3 有没有办法为 CloudWatch 日志组过滤器生成 AWS 控制台 URL? - Is there a way to generate the AWS Console URLs for CloudWatch Log Group filters? 为什么无法更改AWS CloudWatch日志组和流名称? - Why AWS CloudWatch Log Group and Stream Name cannot be changed? 将日志从 AWS Cloudwatch 日志组发送到 Opendistro EFK - Ship logs from AWS Cloudwatch log group to Opendistro EFK 使用 Terraform 将 AWS Lambda 日志写入 CloudWatch 日志组 - Write AWS Lambda Logs to CloudWatch Log Group with Terraform 适用于Elasticbeanstalk的AWS CloudWatch日志 - aws cloudwatch log for elasticbeanstalk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM