Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. Is it possible to rename such a log group? I could find no option to do this via the CloudWatch console.

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.

like image 885
Anders Rabo Thorbeck Avatar asked Mar 06 '17 16:03

Anders Rabo Thorbeck


People also ask

How do you get the log group name in CloudWatch?

Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/ . In the navigation pane, choose Log groups. Choose Actions, and then choose Create log group. Enter a name for the log group, and then choose Create log group.

Can CloudWatch logs be modified?

CloudWatch Logs Use caseslog retention setting can be modified, so that any log events older than this setting are automatically deleted.

How do I rename my CloudWatch alarm?

You can't change the name of an existing alarm. You can copy an alarm and give the new alarm a different name. To copy an alarm, select the check box next to the alarm name in the alarm list and choose Action, Copy. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/ .

Which key contains the name Group of the Amazon CloudWatch logs?

Encryption using AWS KMS is enabled at the log group level, by associating a key with a log group, either when you create the log group or after it exists. CloudWatch Logs now supports encryption context, using kms:EncryptionContext:aws:logs:arn as the key and the ARN of the log group as the value for that key.


1 Answers

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:

  • create-log-group
  • delete-log-group
  • describe-log-groups
  • list-tags-log-group
  • tag-log-group
  • untag-log-group

My solution, since the log-group was only recently created and all the original log files were still on the EC2 instance, was to:

  1. stop the CloudWatch Logs agent on the EC2 instance with $ /etc/init.d/awslogs stop.
  2. ensure the application was not currently running/logging on the EC2 instance
  3. delete the existing log-group on CloudWatch
  4. move the existing log files out of the expected directory on the EC2 instance
  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.
  6. start the CloudWatch Logs agent on the EC2 instance with $ /etc/init.d/awslogs start.
  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.
  8. restart the application on the EC2 instance

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.

like image 161
Anders Rabo Thorbeck Avatar answered Nov 15 '22 09:11

Anders Rabo Thorbeck