-
Notifications
You must be signed in to change notification settings - Fork 283
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
Add opt-in metrics to CloudWatch agent #988
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Report on memory and disk usage
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# shellcheck disable=SC2094 | ||
set -euo pipefail | ||
|
||
if [[ "${CLOUDWATCH_ENABLE_METRICS:-false}" == "true" ]]; then | ||
cw_config="/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json" | ||
cat <<<"$(jq \ | ||
--arg queue "$BUILDKITE_QUEUE" \ | ||
'. + { | ||
metrics: { | ||
metrics_collected: { | ||
mem: {measurement: ["mem_used_percent"], append_dimensions: {BuildkiteQueue: $queue}}, | ||
disk: {measurement: ["used_percent"], resources: ["*"], append_dimensions: {BuildkiteQueue: $queue}} | ||
}, | ||
append_dimensions: { | ||
AutoScalingGroupName: "${aws:AutoScalingGroupName}" | ||
} | ||
} | ||
}' $cw_config)" >$cw_config | ||
Comment on lines
+6
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so looks like this will append to https://github.com/buildkite/elastic-ci-stack-for-aws/blob/509802db39718c8e0623535804237fed35f6f516/packer/linux/conf/cloudwatch-agent/config.json so that the existing file doesn't get clobbered? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it actually rewrites it. It's the same pattern used to configure docker, albeit more complicated.
It's equivalent to: new_config=$(jq <filter> $cw_config)
echo $new_config | cat > $cw_config From what I understand, the combination of here-string and command substitution will use a temp file or memory to avoid any race condition while modifying the file in place. |
||
fi | ||
|
||
# Enable and start amazon-cloudwatch-agent | ||
systemctl enable amazon-cloudwatch-agent | ||
systemctl start amazon-cloudwatch-agent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're adding the queue as dimension for memory and disk, should we do it for CPU too?