-
Notifications
You must be signed in to change notification settings - Fork 212
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
Reduce timeout for scrapping IMDS and give instruction when fail to scrape IMDS inside container #480
Merged
+381
−376
Merged
Reduce timeout for scrapping IMDS and give instruction when fail to scrape IMDS inside container #480
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
66938d2
Fix Aggregrator Shut Down Behavior
khanhntd 7fe088f
Always setting hops to 2 if CloudWatchAgent is deployed as container
khanhntd dada4fe
Reduce timeout for scrapping IMDS and give instrucstion when timeout-…
khanhntd 158ccd5
Reduce timeout for scrapping IMDS and give instrucstion when timeout-…
khanhntd 2c3c8e6
Reduce timeout for scrapping IMDS and give instrucstion when timeout-…
khanhntd 1f72e10
Reduce timeout for scrapping IMDS and give instrucstion when timeout-…
khanhntd 1ca4068
Reduce timeout for scrapping IMDS and give instrucstion when timeout-…
khanhntd e699593
Reduce timeout for scrapping IMDS and give instrucstion when timeout-…
khanhntd 0910c4e
Reduce timeout for scrapping IMDS and give instruction when fail to s…
khanhntd 9921a14
Reduce timeout for scrapping IMDS and give instruction when fail to s…
khanhntd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package ec2tagger | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// Reminder, keep this in sync with the plugin's README.md | ||
const sampleConfig = ` | ||
## | ||
## ec2tagger calls AWS api to fetch EC2 Metadata and Instance Tags and EBS Volumes associated with the | ||
## current EC2 Instance and attached those values as tags to the metric. | ||
## | ||
## Frequency for the plugin to refresh the EC2 Instance Tags and ebs Volumes associated with this Instance. | ||
## Defaults to 0 (no refresh). | ||
## When it is zero, ec2tagger doesn't do refresh to keep the ec2 tags and ebs volumes updated. However, as the | ||
## AWS api request made by ec2tagger might not return the complete values (e.g. initial api call might return a | ||
## subset of ec2 tags), ec2tagger will retry every 3 minutes until all the tags/volumes (as specified by | ||
## "ec2_instance_tag_keys"/"ebs_device_keys") are retrieved successfully. (Note when the specified list is ["*"], | ||
## there is no way to check if all tags/volumes are retrieved, so there is no retry in that case) | ||
# refresh_interval_seconds = 60 | ||
## | ||
## Add tags for EC2 Metadata fields. | ||
## Supported fields are: "InstanceId", "ImageId" (aka AMI), "InstanceType" | ||
## If the configuration is not provided or it has an empty list, no EC2 Metadata tags are applied. | ||
# ec2_metadata_tags = ["InstanceId", "ImageId", "InstanceType"] | ||
## | ||
## Add tags retrieved from the EC2 Instance Tags associated with this instance. | ||
## If this configuration is not provided, or has an empty list, no EC2 Instance Tags are applied. | ||
## If this configuration contains one entry and its value is "*", then ALL EC2 Instance Tags for the instance are applied. | ||
## Note: This plugin renames the "aws:autoscaling:groupName" EC2 Instance Tag key to be spelled "AutoScalingGroupName". | ||
## This aligns it with the AutoScaling dimension-name seen in AWS CloudWatch. | ||
# ec2_instance_tag_keys = ["aws:autoscaling:groupName", "Name"] | ||
## | ||
## Retrieve ebs_volume_id for the specified devices, add ebs_volume_id as tag. The specified devices are | ||
## the values corresponding to the tag key "disk_device_tag_key" in the input metric. | ||
## If this configuration is not provided, or has an empty list, no ebs volume is applied. | ||
## If this configuration contains one entry and its value is "*", then all ebs volume for the instance are applied. | ||
# ebs_device_keys = ["/dev/xvda", "/dev/nvme0n1"] | ||
## | ||
## Specify which tag to use to get the specified disk device name from input Metric | ||
# disk_device_tag_key = "device" | ||
## | ||
## Amazon Credentials | ||
## Credentials are loaded in the following order | ||
## 1) Assumed credentials via STS if role_arn is specified | ||
## 2) explicit credentials from 'access_key' and 'secret_key' | ||
## 3) shared profile from 'profile' | ||
## 4) environment variables | ||
## 5) shared credentials file | ||
## 6) EC2 Instance Profile | ||
# access_key = "" | ||
# secret_key = "" | ||
# token = "" | ||
# role_arn = "" | ||
# profile = "" | ||
# shared_credential_file = "" | ||
` | ||
|
||
const ( | ||
ec2InstanceTagKeyASG = "aws:autoscaling:groupName" | ||
cwDimensionASG = "AutoScalingGroupName" | ||
mdKeyInstanceId = "InstanceId" | ||
mdKeyImageId = "ImageId" | ||
mdKeyInstanceType = "InstanceType" | ||
ebsVolumeId = "EBSVolumeId" | ||
) | ||
|
||
const ( | ||
allowedIMDSRetries = 2 | ||
) | ||
|
||
var ( | ||
defaultIMDSTimeout = 1 * time.Second | ||
defaultRefreshInterval = 180 * time.Second | ||
backoffSleepArray = []time.Duration{0, 1 * time.Minute, 1 * time.Minute, 3 * time.Minute, 3 * time.Minute, 3 * time.Minute, 10 * time.Minute} // backoff retry for ec2 describe instances API call. Assuming the throttle limit is 20 per second. 10 mins allow 12000 API calls. | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should be a random number imo. Think all systems send out the call at the same time. Then next round they all send at the same time. It needs to be random within an interval. This comment is probs out of scope for this pr but something to think about for best behaved agents. @straussb thoughts.