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

CloudwatchAgent on executors #408

Closed
kayman-mk opened this issue Nov 13, 2021 Discussed in #347 · 4 comments
Closed

CloudwatchAgent on executors #408

kayman-mk opened this issue Nov 13, 2021 Discussed in #347 · 4 comments

Comments

@kayman-mk
Copy link
Collaborator

Discussed in #347

Originally posted by npeyrussie July 21, 2021
Hello,

I am looking for a way to install CloudwatchAgent on the executors.
I seems that userdata_pre_install and userdata_post_install only apply to the runner and not to the executors.

What type of detailed monitoring metrics are added thanks to runner_instance_enable_monitoring option ?

I need to retrieve memory metrics in cloudwatch and need to have cloudwatch agent installed on executors.
Is there a way to achieve this ?

@kayman-mk
Copy link
Collaborator Author

Seems to be a valid use case to me.

@npeyrussie Any chance to implement it here?

@npeyrussie
Copy link

Hello,

Using version 4.24.1 of npalm/gitlab-runner/aws, I succeeded in configuring cloudwatch agent using :

docker_machine_iam_policy_arns = ["arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"]

And a dirty post install script as is :

userdata_post_install = <<EOT
cat <<EOF > /root/runner_init.sh
#!/bin/sh
wget https://s3.eu-west-3.amazonaws.com/amazoncloudwatch-agent-eu-west-3/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
dpkg -i -E ./amazon-cloudwatch-agent.deb
mkdir -p /usr/share/collectd
touch /usr/share/collectd/types.db
cat <<'EOS' > /opt/aws/amazon-cloudwatch-agent/bin/config.json
{
        "agent": {
                "metrics_collection_interval": 60,
                "run_as_user": "root"
        },
        "metrics": {
                "append_dimensions": {
                        "AutoScalingGroupName": "DOLLAR{aws:AutoScalingGroupName}",
                        "ImageId": "DOLLAR{aws:ImageId}",
                        "InstanceId": "DOLLAR{aws:InstanceId}",
                        "InstanceType": "DOLLAR{aws:InstanceType}"
                },
                "metrics_collected": {
                        "collectd": {
                                "metrics_aggregation_interval": 60
                        },
                        "disk": {
                                "measurement": [
                                        "used_percent"
                                ],
                                "metrics_collection_interval": 60,
                                "resources": [
                                        "*"
                                ]
                        },
                        "mem": {
                                "measurement": [
                                        "mem_used_percent"
                                ],
                                "metrics_collection_interval": 60
                        },
                        "statsd": {
                                "metrics_aggregation_interval": 60,
                                "metrics_collection_interval": 10,
                                "service_address": ":8125"
                        }
                }
        }
}
EOS
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a start -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
EOF
sed -i 's/DOLLAR/\$/g' /root/runner_init.sh
EOT

Regards.

@npalm
Copy link
Collaborator

npalm commented Dec 1, 2021

Can we close the question?

@npeyrussie
Copy link

Hello @npalm , I think you can close it.

Regards.

@npalm npalm closed this as completed Dec 3, 2021
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

3 participants