From d037c4a3f4aa7ae0d619b6ba05a736edb934f6ee Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Tue, 16 Jun 2020 10:55:50 -0600 Subject: [PATCH 1/4] Remove dedot for AWS tag value --- x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go | 5 +++-- x-pack/metricbeat/module/aws/ec2/ec2.go | 5 +++-- x-pack/metricbeat/module/aws/rds/rds.go | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go b/x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go index 2ec9fe5461e..2cc447723be 100644 --- a/x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go +++ b/x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go @@ -616,9 +616,10 @@ func insertTags(events map[string]mb.Event, identifier string, resourceTagMap ma for _, v := range subIdentifiers { tags := resourceTagMap[v] if len(tags) != 0 { - // By default, replace dot "." using underscore "_" for tag keys and values + // By default, replace dot "." using underscore "_" for tag keys. + // Note: tag values are not dedotted. for _, tag := range tags { - events[identifier].RootFields.Put("aws.tags."+common.DeDot(*tag.Key), common.DeDot(*tag.Value)) + events[identifier].RootFields.Put("aws.tags."+common.DeDot(*tag.Key), *tag.Value) } continue } diff --git a/x-pack/metricbeat/module/aws/ec2/ec2.go b/x-pack/metricbeat/module/aws/ec2/ec2.go index 9e9c9467829..609c7bbdd01 100644 --- a/x-pack/metricbeat/module/aws/ec2/ec2.go +++ b/x-pack/metricbeat/module/aws/ec2/ec2.go @@ -197,9 +197,10 @@ func (m *MetricSet) createCloudWatchEvents(getMetricDataResults []cloudwatch.Met } } - // By default, replace dot "." using under bar "_" for tag keys and values + // By default, replace dot "." using under bar "_" for tag keys. + // Note: tag values are not dedotted. for _, tag := range tags { - events[instanceID].ModuleFields.Put("tags."+common.DeDot(*tag.Key), common.DeDot(*tag.Value)) + events[instanceID].ModuleFields.Put("tags."+common.DeDot(*tag.Key), *tag.Value) } machineType, err := instanceOutput[instanceID].InstanceType.MarshalValue() diff --git a/x-pack/metricbeat/module/aws/rds/rds.go b/x-pack/metricbeat/module/aws/rds/rds.go index 6c1ca1c8b19..0e4f0e4bd44 100644 --- a/x-pack/metricbeat/module/aws/rds/rds.go +++ b/x-pack/metricbeat/module/aws/rds/rds.go @@ -207,11 +207,12 @@ func (m *MetricSet) getDBInstancesPerRegion(svc rdsiface.ClientAPI) ([]string, m } for _, tag := range outputListTags.TagList { - // By default, replace dot "." using under bar "_" for tag keys and values + // By default, replace dot "." using under bar "_" for tag keys. + // Note: tag values are not dedotted. dbDetails.tags = append(dbDetails.tags, aws.Tag{ Key: common.DeDot(*tag.Key), - Value: common.DeDot(*tag.Value), + Value: *tag.Value, }) } dbDetailsMap[*dbInstance.DBInstanceIdentifier] = dbDetails From 5d8fc7e38ac15ef924e7e5c17bcc4afbec724a6b Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Tue, 16 Jun 2020 11:02:35 -0600 Subject: [PATCH 2/4] add changelog --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index b587467fcd6..3c94b250ac4 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -249,6 +249,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fix compute and pubsub dashboard for googlecloud module. {issue}18962[18962] {pull}18980[18980] - Fix crash on vsphere module when Host information is not available. {issue}18996[18996] {pull}19078[19078] - Fix incorrect usage of hints builder when exposed port is a substring of the hint {pull}19052[19052] +- Remove dedot for tag values in aws module. {issue}19112[19112] {pull}19221[19221] *Packetbeat* From 706f41f3eb07958298e13876b5761de418cebbf2 Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Tue, 16 Jun 2020 21:44:14 -0600 Subject: [PATCH 3/4] Fix unit test --- x-pack/metricbeat/module/aws/rds/rds_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/metricbeat/module/aws/rds/rds_test.go b/x-pack/metricbeat/module/aws/rds/rds_test.go index 016ffda4434..5537ecd430b 100644 --- a/x-pack/metricbeat/module/aws/rds/rds_test.go +++ b/x-pack/metricbeat/module/aws/rds/rds_test.go @@ -146,7 +146,7 @@ func TestGetDBInstancesPerRegion(t *testing.T) { dbIdentifier: dbInstanceIdentifier, dbStatus: dbInstanceStatus, tags: []aws.Tag{ - {Key: "dept_name", Value: "eng_software"}, + {Key: "dept_name", Value: "eng.software"}, {Key: "created-by", Value: "foo"}, }, } @@ -177,7 +177,7 @@ func TestGetDBInstancesPerRegionWithTagsFilter(t *testing.T) { dbIdentifier: dbInstanceIdentifier, dbStatus: dbInstanceStatus, tags: []aws.Tag{ - {Key: "dept_name", Value: "eng_software"}, + {Key: "dept_name", Value: "eng.software"}, {Key: "created-by", Value: "foo"}, }, } @@ -208,7 +208,7 @@ func TestGetDBInstancesPerRegionWithDotInTag(t *testing.T) { dbIdentifier: dbInstanceIdentifier, dbStatus: dbInstanceStatus, tags: []aws.Tag{ - {Key: "dept_name", Value: "eng_software"}, + {Key: "dept_name", Value: "eng.software"}, {Key: "created-by", Value: "foo"}, }, } From d64cc1305be1e17a364c220781fc31b8cd6b14f2 Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Wed, 17 Jun 2020 07:05:58 -0600 Subject: [PATCH 4/4] Fix under bar to underscore --- x-pack/metricbeat/module/aws/ec2/ec2.go | 2 +- x-pack/metricbeat/module/aws/rds/rds.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/metricbeat/module/aws/ec2/ec2.go b/x-pack/metricbeat/module/aws/ec2/ec2.go index 609c7bbdd01..6e597c61c25 100644 --- a/x-pack/metricbeat/module/aws/ec2/ec2.go +++ b/x-pack/metricbeat/module/aws/ec2/ec2.go @@ -197,7 +197,7 @@ func (m *MetricSet) createCloudWatchEvents(getMetricDataResults []cloudwatch.Met } } - // By default, replace dot "." using under bar "_" for tag keys. + // By default, replace dot "." using underscore "_" for tag keys. // Note: tag values are not dedotted. for _, tag := range tags { events[instanceID].ModuleFields.Put("tags."+common.DeDot(*tag.Key), *tag.Value) diff --git a/x-pack/metricbeat/module/aws/rds/rds.go b/x-pack/metricbeat/module/aws/rds/rds.go index 0e4f0e4bd44..f8bd907b3f6 100644 --- a/x-pack/metricbeat/module/aws/rds/rds.go +++ b/x-pack/metricbeat/module/aws/rds/rds.go @@ -207,7 +207,7 @@ func (m *MetricSet) getDBInstancesPerRegion(svc rdsiface.ClientAPI) ([]string, m } for _, tag := range outputListTags.TagList { - // By default, replace dot "." using under bar "_" for tag keys. + // By default, replace dot "." using underscore "_" for tag keys. // Note: tag values are not dedotted. dbDetails.tags = append(dbDetails.tags, aws.Tag{