aws / aws/amazon-cloudwatch-agent

[Feature Request] environment_name variable option for log_group_name in Logs section

Open
#224 7 comments 8 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
550
Forks
271
Avg merge
1d 21h
Merged PRs (30d)
13

Description

For our use case, we have the cloudwatch agent sending the logs from EC2 instance managed by AWS Beanstalk.

Apart from the pre-configured standard logs provided by the Beanstalk environment, we want to send other logs as well. We have multiple environments (dev/qa/prod) that send logs to Cloudwatch Logs and the defaults do provide the environment name in the `log_group_name` which is helpful.

I have tried to replicate something similar for my custom logs before realizing that we can only provide `{instance_id}`, `{hostname}`, `{local_hostname}`, and `{ip_address}` as variables within the name from the [docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html#CloudWatch-Agent-Configuration-File-Logssection).

I did try something like
```json
{
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/va/log/my_custom.log",
"log_group_name": "{ 'Fn::Sub': '/aws/elasticbeanstalk/${AWSEBEnvironmentName}/var/log/my_custom.log' }",
"log_stream_name": "{instance_id}"
},
...,
]
}
}
}
}

```
and a few other combinations but it was not fruitful.

It would be very helpful if something like the `{environment_name}` can also be added as an option which makes it a lot easier to distinguish the different beanstalk environment logs that have the same name as opposed to using the `instance_id` or something else.

Contributor guide

Open the contributing guide

Research direction

The issue names no source file or test. Start by tracing the Logs configuration handling and the linked CloudWatch Agent logs configuration documentation; done means a supported environment-name option is documented and covered by tests for custom log group names.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, go
Domain
observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.