Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AWS Cloudwatch mappings #14653

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions x-pack/metricbeat/module/aws/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@
type: keyword
description: >
Name of a S3 bucket.
- name: dimensions.*
type: object
object_type: keyword
object_type_mapping_type: "*"
description: >
Metric dimensions.
- name: aws.*.metrics.*.*
type: object
object_type: double
object_type_mapping_type: "*"
description: >
Metrics that returned from Cloudwatch api query.
14 changes: 1 addition & 13 deletions x-pack/metricbeat/module/aws/cloudwatch/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,4 @@
- name: namespace
type: keyword
description: >
The namespace specified when query cloudwatch api.
- name: metrics.*.*
type: object
object_type: double
object_type_mapping_type: "*"
description: >
Metrics that returned from Cloudwatch api query.
- name: dimensions.*
type: object
object_type: keyword
object_type_mapping_type: "*"
description: >
Cloudwatch metric dimensions.
The namespace specified when query cloudwatch api.
18 changes: 13 additions & 5 deletions x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,27 +368,35 @@ func statisticLookup(stat string) (string, bool) {
return statMethod, ok
}

func generateFieldName(labels []string) string {
func generateFieldName(namespace string, labels []string) string {
stat := labels[statisticIdx]
// Check if statistic method is one of Sum, SampleCount, Minimum, Maximum, Average
if statMethod, ok := statisticLookup(stat); ok {
return "aws.metrics." + labels[metricNameIdx] + "." + statMethod
return "aws." + stripNamespace(namespace) + ".metrics." + labels[metricNameIdx] + "." + statMethod
}
// If not, then it should be a percentile in the form of pN
return "metrics." + labels[metricNameIdx] + "." + stat
}

// stripNamespace converts Cloudwatch namespace into the root field we will use for metrics
// example AWS/EC2 -> ec2
func stripNamespace(namespace string) string {
parts := strings.Split(namespace, "/")
return strings.ToLower(parts[len(parts)-1])
}

func insertRootFields(event mb.Event, metricValue float64, labels []string) mb.Event {
event.RootFields.Put(generateFieldName(labels), metricValue)
event.RootFields.Put("aws.cloudwatch.namespace", labels[namespaceIdx])
namespace := labels[namespaceIdx]
event.RootFields.Put(generateFieldName(namespace, labels), metricValue)
event.RootFields.Put("aws.cloudwatch.namespace", namespace)
if len(labels) == 3 {
return event
}

dimNames := strings.Split(labels[identifierNameIdx], ",")
dimValues := strings.Split(labels[identifierValueIdx], ",")
for i := 0; i < len(dimNames); i++ {
event.RootFields.Put("aws.cloudwatch.dimensions."+dimNames[i], dimValues[i])
event.RootFields.Put("aws.dimensions."+dimNames[i], dimValues[i])
}
return event
}
Expand Down
27 changes: 20 additions & 7 deletions x-pack/metricbeat/module/aws/cloudwatch/cloudwatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,44 +652,57 @@ func TestReadCloudwatchConfig(t *testing.T) {
func TestGenerateFieldName(t *testing.T) {
cases := []struct {
title string
metricsetName string
label []string
expectedFieldName string
}{
{
"test Average",
"cloudwatch",
[]string{"CPUUtilization", "AWS/EC2", "Average", "InstanceId", "i-1"},
"aws.metrics.CPUUtilization.avg",
"aws.cloudwatch.metrics.CPUUtilization.avg",
},
{
"test Maximum",
"cloudwatch",
[]string{"CPUUtilization", "AWS/EC2", "Maximum", "InstanceId", "i-1"},
"aws.metrics.CPUUtilization.max",
"aws.cloudwatch.metrics.CPUUtilization.max",
},
{
"test Minimum",
"cloudwatch",
[]string{"CPUUtilization", "AWS/EC2", "Minimum", "InstanceId", "i-1"},
"aws.metrics.CPUUtilization.min",
"aws.cloudwatch.metrics.CPUUtilization.min",
},
{
"test Sum",
"cloudwatch",
[]string{"CPUUtilization", "AWS/EC2", "Sum", "InstanceId", "i-1"},
"aws.metrics.CPUUtilization.sum",
"aws.cloudwatch.metrics.CPUUtilization.sum",
},
{
"test SampleCount",
"cloudwatch",
[]string{"CPUUtilization", "AWS/EC2", "SampleCount", "InstanceId", "i-1"},
"aws.metrics.CPUUtilization.count",
"aws.cloudwatch.metrics.CPUUtilization.count",
},
{
"test extended statistic",
"cloudwatch",
[]string{"CPUUtilization", "AWS/EC2", "p10", "InstanceId", "i-1"},
"aws.metrics.CPUUtilization.p10",
"aws.cloudwatch.metrics.CPUUtilization.p10",
},
{
"test other metricset",
"ec2",
[]string{"CPUUtilization", "AWS/EC2", "p10", "InstanceId", "i-1"},
"aws.ec2.metrics.CPUUtilization.p10",
},
}

for _, c := range cases {
t.Run(c.title, func(t *testing.T) {
fieldName := generateFieldName(c.label)
fieldName := generateFieldName(c.metricsetName, c.label)
assert.Equal(t, c.expectedFieldName, fieldName)
})
}
Expand Down
61 changes: 34 additions & 27 deletions x-pack/metricbeat/module/aws/ebs/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,49 @@
"@timestamp": "2017-10-12T08:05:34.853Z",
"aws": {
"cloudwatch": {
"dimensions": {
"VolumeId": "vol-6ae467c0"
},
"namespace": "AWS/EBS"
},
"metrics": {
"BurstBalance": {
"avg": 100
},
"VolumeIdleTime": {
"sum": 299.97
},
"VolumeQueueLength": {
"avg": 0.0001
},
"VolumeReadOps": {
"avg": 0
},
"VolumeTotalWriteTime": {
"sum": 0.03
},
"VolumeWriteBytes": {
"avg": 10330.79802955665
},
"VolumeWriteOps": {
"avg": 203
"dimensions": {
"VolumeId": "vol-0f3766bc5920c34de"
},
"ebs": {
"metrics": {
kaiyan-sheng marked this conversation as resolved.
Show resolved Hide resolved
"BurstBalance": {
"avg": 99.9467222222222
},
"VolumeIdleTime": {
"sum": 599.83
},
"VolumeQueueLength": {
"avg": 0.003533333333333335
},
"VolumeReadBytes": {
"avg": 30935.57894736842
},
"VolumeReadOps": {
"avg": 19
},
"VolumeTotalReadTime": {
"sum": 0.02
},
"VolumeTotalWriteTime": {
"sum": 2.0999999999999996
},
"VolumeWriteBytes": {
"avg": 11735.04
},
"VolumeWriteOps": {
"avg": 262.5
}
}
}
},
"cloud": {
"account": {
"id": "627959692251",
"name": "elastic-test"
"id": "856482450085"
},
"provider": "aws",
"region": "us-east-1"
"region": "us-west-2"
},
"event": {
"dataset": "aws.ebs",
Expand Down
41 changes: 19 additions & 22 deletions x-pack/metricbeat/module/aws/elb/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,34 @@
"@timestamp": "2017-10-12T08:05:34.853Z",
"aws": {
"cloudwatch": {
"dimensions": {
"LoadBalancerName": "tf-lb-20171218185946539900000004"
},
"namespace": "AWS/ELB"
},
"metrics": {
"EstimatedALBActiveConnectionCount": {
"avg": 2.6
},
"EstimatedALBConsumedLCUs": {
"avg": 0.000015000000000000002
},
"EstimatedALBNewConnectionCount": {
"avg": 0
},
"EstimatedProcessedBytes": {
"avg": 237.6
}
"dimensions": {
"LoadBalancerName": "asdff"
},
"tags": {
"Name": "logstash",
"owner": "logstash"
"elb": {
"metrics": {
"EstimatedALBActiveConnectionCount": {
"avg": 3
},
"EstimatedALBConsumedLCUs": {
"avg": 0.0002375
},
"EstimatedALBNewConnectionCount": {
"avg": 21.25
},
"EstimatedProcessedBytes": {
"avg": 192.5
}
}
}
},
"cloud": {
"account": {
"id": "627959692251",
"name": "elastic-test"
"id": "856482450085"
},
"provider": "aws",
"region": "us-east-1"
"region": "us-west-2"
},
"event": {
"dataset": "aws.elb",
Expand Down
52 changes: 25 additions & 27 deletions x-pack/metricbeat/module/aws/elb/_meta/data_nlb.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,40 @@
"@timestamp": "2017-10-12T08:05:34.853Z",
"aws": {
"cloudwatch": {
"dimensions": {
"LoadBalancer": "net/filebeat-aws-elb-test-tcp-lb/d194184ba08f017f"
},
"namespace": "AWS/NetworkELB"
},
"metrics": {
"ActiveFlowCount": {
"avg": 0
},
"ConsumedLCUs": {
"avg": 0
},
"NewFlowCount": {
"sum": 0
},
"ProcessedBytes": {
"sum": 336
},
"TCP_Client_Reset_Count": {
"sum": 0
},
"TCP_ELB_Reset_Count": {
"sum": 0
},
"TCP_Target_Reset_Count": {
"sum": 0
"dimensions": {
"LoadBalancer": "net/asdfe/3b2c2530f0b34305"
},
"networkelb": {
"metrics": {
"ConsumedLCUs": {
"avg": 0
},
"NewFlowCount": {
"sum": 0
},
"ProcessedBytes": {
"sum": 0
},
"TCP_Client_Reset_Count": {
"sum": 0
},
"TCP_ELB_Reset_Count": {
"sum": 0
},
"TCP_Target_Reset_Count": {
"sum": 0
}
}
}
},
"cloud": {
"account": {
"id": "627959692251",
"name": "elastic-test"
"id": "856482450085"
},
"provider": "aws",
"region": "ap-southeast-1"
"region": "us-west-2"
},
"event": {
"dataset": "aws.elb",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/metricbeat/module/aws/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.