-
Notifications
You must be signed in to change notification settings - Fork 8
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
Embed fargate data in container samples #50
Conversation
b102213
to
b2d7530
Compare
58b0bc2
to
fdecd66
Compare
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.
looks good thanks for adding the test
src/raw/aws/fargate_inspector.go
Outdated
// resourceNameAndARNBase explodes a resource ARN and returns the resource's name and the base ARN prefix for the | ||
// account and region of the original resource. | ||
func resourceNameAndARNBase(resourceARN string) (resourceName string, arnPrefix string) { | ||
arnPrefixAndType := resourceARN[:strings.Index(resourceARN, "/")-1] |
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.
Can we use the strings.Split function instead as in the previous method?
Only to avoid splitting using indexes directly
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.
Both functions were taken (i.e. copy-pasted) from nri-ecs, and were left untouched for consistency even when I do not particularly like the implementation of either. The one that uses split, for example, does not perform any kind of bound-checking and relies on the passed string to be an arn.
If we are ok with changing them, I'd vote for rewriting both of them to use strings.Split
and proper bound checking. What do you think?
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.
Only a small comments, I believe it is fine, but if we can I would use the standard function 👍
Well done!
fagate_inspector: add launch-type label unconditionally
fdecd66
to
7215d83
Compare
bb033b2
to
a98fd4d
Compare
Following a conversation with @paologallinaharbur, we decided that the best approach for now would be to include the aws sdk even for this tiny bit (arn parsing), and file an issue to switch to said SDK for everything else (hopefully removing all manually vendored files) |
Fixes #49
When running in transparent mode, as is the case in Fargate, the agent will not decorate metrics with Fargate metadata such as
awsRegion
,ecsLaunchType
, andecsClusterName
. Breaking queries that use such attributes.In this PR we fix this by pulling such metadata from the docker container labels that Fargate adds to the container information, by parsing the task arn and the cluster name. This is the same way in which https://github.com/newrelic/nri-ecs obtains this information.
RegionFromTask
andResourceNameAndARNBase
have been pulled from said repo as well.TODO:
Manual testing checklist
FARGATE
andNRIA_IS_FORWARD_ONLY
are setjson-comparison.tar.gz