-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[AWS] Fix ec2 host.cpu.usage + include instance metadata and rate metrics for linked monitoring accounts #35717
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
thanks kaiyan! why does moving |
@tommyers-elastic WDYT about adding the value from dynamic label |
This pull request is now in conflicts. Could you fix it? 🙏
|
} | ||
|
||
// add instance ID from dimension value | ||
dimInstanceID, _ := events[eventIdentifier].RootFields.GetValue("aws.dimensions.InstanceId") |
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.
does this always exist in the dimensions? should we check the error here just in case?
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.
Yeah good point! Will add it!
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.
I did some testing on this, when aws.dimensions.InstanceId
doesn't exist, dimInstanceID
returns as nil. Then events[eventIdentifier].RootFields.Put("cloud.instance.id", dimInstanceID)
will just put nil as the value for cloud.instance.id
which won't show up in the event.
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.
😬 that wouldn't be ideal - i wonder if we could fall back to the instance ID we from the loop var?
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.
I added the error check here to make sure only put value to cloud.instance.id
when aws.dimensions.InstanceId
exists. We can't use instance ID from the inner for loop var because that for loop is going through all the instances metadata from DescribeInstances
API. We are trying to use the two for loops to match events with the dimension InstanceId to the same ID from DescribeInstances
.
@kaiyan-sheng if the period isn't used for anything in kibana, i don't think we should add it. we can always add it later if we find a need. since we now have period and account name as dyamic labels, do we have any idea if this adds any additional overhead to the getmetricdata calls? |
@tommyers-elastic Good point! I made a bash script and ran the AWS GetMetricData CLI call several times for both with and without getting the dynamic labels. The average time spent on GetMetricData is about the same. for example some data points look like this:
and
By looking at several sets of output, I think we can say adding the dynamic label doesn't add overhead on the API call. |
…e metadata and rate metrics for linked monitoring accounts (#35816) * [AWS] Fix ec2 host.cpu.usage + include instance metadata and rate metrics for linked monitoring accounts (#35717) (cherry picked from commit 36aa884) --------- Co-authored-by: kaiyan-sheng <[email protected]>
…e metadata and rate metrics for linked monitoring accounts (#35817) * [AWS] Fix ec2 host.cpu.usage + include instance metadata and rate metrics for linked monitoring accounts (#35717) (cherry picked from commit 36aa884) Co-authored-by: kaiyan-sheng <[email protected]>
What does this PR do?
This PR is fixing two bugs:
host.cpu.usage
metric for EC2: apparently it is looking for the wrong metric name. It should beaws.ec2.metrics.CPUUtilization.avg
.addHostFields
andcalculateRate
functions are getting skipped when collecting metrics from linked accounts: because when adding metadata, we are making an additional API call to list all EC2 instances in that account and use that list/return value to add metadata. During this process, we only add metadata to instances from the monitoring account becauseDescribeInstances
does not have access to linked source accounts. This case, we should moveaddHostFields
andcalculateRate
functions to the beginning when adding meta data. This way, both monitoring account and linked source accounts instances will have host fields and rate. The actual metadata can be added later just for the instances in monitoring account.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues