Skip to content

Commit

Permalink
[Metricbeat] Add dedot for cloudwatch metric name (elastic#15917)
Browse files Browse the repository at this point in the history
* Add dedot for cloudwatch metric name
* update changelog
  • Loading branch information
kaiyan-sheng authored Jan 28, 2020
1 parent 150fbb8 commit 5193ce9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

- Add dedot for tags in ec2 metricset and cloudwatch metricset. {issue}15843[15843] {pull}15844[15844]
- Use RFC3339 format for timestamps collected using the SQL module. {pull}15847[15847]
- Add dedot for cloudwatch metric name. {issue}15916[15916] {pull}15917[15917]

*Packetbeat*

Expand Down
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ func generateFieldName(namespace string, labels []string) string {
// Check if statistic method is one of Sum, SampleCount, Minimum, Maximum, Average
// With checkStatistics function, no need to check bool return value here
statMethod, _ := statisticLookup(stat)
return "aws." + stripNamespace(namespace) + ".metrics." + labels[metricNameIdx] + "." + statMethod
// By default, replace dot "." using under bar "_" for metric names
return "aws." + stripNamespace(namespace) + ".metrics." + common.DeDot(labels[metricNameIdx]) + "." + statMethod
}

// stripNamespace converts Cloudwatch namespace into the root field we will use for metrics
Expand Down
6 changes: 6 additions & 0 deletions x-pack/metricbeat/module/aws/cloudwatch/cloudwatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,12 @@ func TestGenerateFieldName(t *testing.T) {
[]string{"CPUUtilization", "AWS/EC2", "p10", "InstanceId", "i-1"},
"aws.ec2.metrics.CPUUtilization.p10",
},
{
"test metric name with dot",
"cloudwatch",
[]string{"DeliveryToS3.Records", "AWS/Firehose", "Average", "DeliveryStreamName", "test-1"},
"aws.firehose.metrics.DeliveryToS3_Records.avg",
},
}

for _, c := range cases {
Expand Down

0 comments on commit 5193ce9

Please sign in to comment.