Skip to content

Commit

Permalink
[Metricbeat] Fix ARN parsing function to work for ELB ANRs (#14316)
Browse files Browse the repository at this point in the history
* Fix findIdentifierFromARN to work for elb arns
  • Loading branch information
kaiyan-sheng committed Oct 29, 2019
1 parent b2f316f commit 61fa974
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix performance counter values for windows/perfmon metricset. {issue}14036[14036] {pull}14039[14039]
- Add FailOnRequired when applying schema and fix metric names in mongodb metrics metricset. {pull}14143[14143]
- Convert indexed ms-since-epoch timestamp fields in `elasticsearch/ml_job` metricset to ints from float64s. {issue}14220[14220] {pull}14222[14222]
- Fix ARN parsing function to work for ELB ARNs. {pull}14316[14316]

*Packetbeat*

Expand Down
7 changes: 5 additions & 2 deletions x-pack/metricbeat/module/aws/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ func findIdentifierFromARN(resourceARN string) (string, error) {
} else if strings.Contains(arnParsed.Resource, "/") {
resourceARNSplit = strings.Split(arnParsed.Resource, "/")
}
identifier := resourceARNSplit[len(resourceARNSplit)-1]
return identifier, nil

if len(resourceARNSplit) <= 1 {
return resourceARNSplit[0], nil
}
return strings.Join(resourceARNSplit[1:], "/"), nil
}
8 changes: 8 additions & 0 deletions x-pack/metricbeat/module/aws/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ func TestFindIdentifierFromARN(t *testing.T) {
"arn:aws:sns:us-east-1:627959692251:notification-topic-1",
"notification-topic-1",
},
{
"arn:aws:elasticloadbalancing:eu-central-1:627959692251:loadbalancer/app/ece-ui/b195d6cf21493989",
"app/ece-ui/b195d6cf21493989",
},
{
"arn:aws:elasticloadbalancing:eu-central-1:627959692251:loadbalancer/net/ece-es-clusters-nlb/0c5bdb3b96cf1552",
"net/ece-es-clusters-nlb/0c5bdb3b96cf1552",
},
}

for _, c := range cases {
Expand Down

0 comments on commit 61fa974

Please sign in to comment.