Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How can I use a custom cloudwatch agent config with a custom AMI #4222

Open
dgokcin opened this issue Oct 30, 2024 · 0 comments
Open

Comments

@dgokcin
Copy link

dgokcin commented Oct 30, 2024

Hello!

I am trying to use a custom AMI for speed up the runner boot time and also to reduce AWSEUC1-DataTransfer-Regional-Bytes costs. When using a user-data script, I build the ${logFiles} value in my terraform module and use it in cloudwatch_config.json like below, to forward the user-data and runner log files to cloudwatch.

What is the recommended way of customizing the cw agent config with the log files?

Thanks!

        #... terraform multi-runner config
        cloudwatch_config = templatefile("${path.module}/templates/cloudwatch_config.json", {
          logfiles = jsonencode([for l in local.github_runner_log_files : {
            "log_group_name" : l.prefix_log_group ? "/github-self-hosted-runners/${local.github_runner_prefix}-ubuntu-large/${l.log_group_name}" : "/${l.log_group_name}"
            "log_stream_name" : l.log_stream_name
            "file_path" : l.file_path
          }])
        })
{
    "agent": {
      "metrics_collection_interval": 3
    },
    "logs": {
        "logs_collected": {
            "files": {
                "collect_list": ${logfiles}
            }
        }
    },
    "metrics": {
      "append_dimensions": {
        "InstanceId": "$${aws:InstanceId}",
        "InstanceType": "$${aws:InstanceType}"
      },
      "metrics_collected": {
        "disk": {
          "resources": ["/", "/tmp"],
          "measurement": [{"name": "disk_used_percent", "unit": "Percent", "rename": "Disk Used (%)"}],
          "ignore_file_system_types": ["sysfs", "devtmpfs"]
        },
        "mem": {
          "measurement": [
            {"name": "mem_available_percent", "unit": "Percent", "rename": "Memory Available (%)"},
            {"name": "mem_cached", "unit": "Bytes", "rename": "Memory Cached"},
            {"name": "mem_total", "unit": "Bytes", "rename": "Memory Total"},
            {"name": "mem_used", "unit": "Bytes", "rename": "Memory Used"}
          ]
        }
      },
      "aggregation_dimensions": [["InstanceId", "InstanceType"], ["InstanceId"]]
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant