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:
- stop the CloudWatch Logs agent on the EC2 instance with
$ /etc/init.d/awslogs stop
.
- ensure the application was not currently running/logging on the EC2 instance
- delete the existing log-group on CloudWatch
- move the existing log files out of the expected directory on the EC2 instance
- edit the file
/var/awslogs/etc/awslogs.conf
on the EC2 instance to specify the desired log group name instead of the previous one.
- start the CloudWatch Logs agent on the EC2 instance with
$ /etc/init.d/awslogs start
.
- 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.
- 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.