Skip to content

Commit

Permalink
[Metricbeat] Add dedot for cloudwatch metric name (elastic#15917) (el…
Browse files Browse the repository at this point in the history
…astic#15918)

* Add dedot for cloudwatch metric name
* update changelog

(cherry picked from commit 5193ce9)
  • Loading branch information
kaiyan-sheng committed Jan 29, 2020
1 parent 8eea6b8 commit 896bdb0
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 @@ -113,6 +113,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix CPU count in docker/cpu in cases where no `online_cpus` are reported {pull}15070[15070]
- 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 896bdb0

Please sign in to comment.