Fix: CloudWatch metadata enrichment failing due to account ID prefix in event identifiers#48712
Open
MichaelKatsoulis wants to merge 4 commits intoelastic:mainfrom
Open
Fix: CloudWatch metadata enrichment failing due to account ID prefix in event identifiers#48712MichaelKatsoulis wants to merge 4 commits intoelastic:mainfrom
MichaelKatsoulis wants to merge 4 commits intoelastic:mainfrom
Conversation
|
This pull request doesn't have a |
Contributor
🤖 GitHub commentsJust comment with:
|
Contributor
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
| // ExtractResourceID extracts the resource identifier from an event identifier. | ||
| // Event identifier format: {accountId}-{resourceId}-{index} | ||
| // Account ID is always 12 digits, so we detect and strip it. | ||
| func ExtractResourceID(eventIdentifier string) string { |
Contributor
There was a problem hiding this comment.
I have one concern, we create identifier as below,
identifierValue := labels[aws.LabelConst.AccountIdIdx] + "-" + labels[aws.LabelConst.IdentifierValueIdx] + fmt.Sprint("-", valI)if labels[aws.LabelConst.IdentifierValueIdx] contain dashes, then this logic can fail 🤔
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed commit message
Problem:
A regression was introduced where
cloudwatch.createEventsstarted prefixing event identifiers with the AWS account ID (format: {accountId}-{resourceId}-{index}). This broke the metadata matching logic in EC2, RDS, and SQS enrichment, causing fields likeaws.ec2.instance.state.name,aws.rds.db_instance.status, andaws.sqs.queue.nameto no longer be populated.Solution:
Created a shared helper
metadata.ExtractResourceID()that detects and strips the 12-digit account ID prefix from event identifiersUpdated
ec2.AddMetadatato useaws.dimensions.InstanceIdas primary source for matching, with fallback to the helperUpdated
rds.AddMetadataandsqs.AddMetadatato use the helper for resource ID extractionChecklist
stresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.Disruptive User Impact
It actually fixes a problem.
Author's Checklist
How to test this PR locally
Deploy metricbeat with this PR code locally and enable aws module
./metricbeat modules enable awsEdit modules.d/aws.yaml
Related issues