Skip to content

Commit

Permalink
Collect cloud.instance.name in ec2 metricset (#20077)
Browse files Browse the repository at this point in the history
* add cloud.instance.name
  • Loading branch information
kaiyan-sheng committed Jul 22, 2020
1 parent 40174bc commit c1055c6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Adds support for app insights metrics in the azure module. {issue}18570[18570] {pull}18940[18940]
- Added cache and connection_errors metrics to status metricset of MySQL module {issue}16955[16955] {pull}19844[19844]
- Update MySQL dashboard with connection errors and cache metrics {pull}19913[19913] {issue}16955[16955]
- Add cloud.instance.name into aws ec2 metricset. {pull}20077[20077]

*Packetbeat*

Expand Down
51 changes: 26 additions & 25 deletions x-pack/metricbeat/module/aws/ec2/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"aws": {
"ec2": {
"cpu": {
"credit_balance": 576,
"credit_usage": 0.217777,
"credit_balance": 144,
"credit_usage": 0.061395,
"surplus_credit_balance": 0,
"surplus_credits_charged": 0,
"total": {
"pct": 2.1374965268131265
"pct": 1.1651199407241788
}
},
"diskio": {
Expand All @@ -27,21 +27,21 @@
},
"instance": {
"core": {
"count": 2
"count": 1
},
"image": {
"id": "ami-f920cd94"
"id": "ami-04bc3da8f14823e88"
},
"monitoring": {
"state": "disabled"
},
"private": {
"dns_name": "ip-10-0-0-148.ec2.internal",
"ip": "10.0.0.148"
"dns_name": "ip-172-31-9-119.us-west-1.compute.internal",
"ip": "172.31.9.119"
},
"public": {
"dns_name": "ec2-54-226-109-162.compute-1.amazonaws.com",
"ip": "54.226.109.162"
"dns_name": "ec2-13-52-163-56.us-west-1.compute.amazonaws.com",
"ip": "13.52.163.56"
},
"state": {
"code": 16,
Expand All @@ -51,16 +51,16 @@
},
"network": {
"in": {
"bytes": 1510123.4,
"bytes_per_sec": 5033.7446666666665,
"packets": 3126.4,
"packets_per_sec": 10.421333333333333
"bytes": 7375.4,
"bytes_per_sec": 24.584666666666667,
"packets": 49,
"packets_per_sec": 0.16333333333333333
},
"out": {
"bytes": 464863,
"bytes_per_sec": 1549.5433333333333,
"packets": 3031.2,
"packets_per_sec": 10.104
"bytes": 11567,
"bytes_per_sec": 38.556666666666665,
"packets": 44.8,
"packets_per_sec": 0.14933333333333332
}
},
"status": {
Expand All @@ -70,24 +70,25 @@
}
},
"tags": {
"Cost": "$614.01",
"Name": "container-registry-test-ui.elastic.co"
"Name": "mysql-test",
"created-by": "ks"
}
},
"cloud": {
"account": {
"id": "627959692251",
"name": "elastic-test"
"id": "428152502467",
"name": "elastic-beats"
},
"availability_zone": "us-east-1b",
"availability_zone": "us-west-1b",
"instance": {
"id": "i-77f84332"
"id": "i-0516ddaca5c1d231f",
"name": "mysql-test"
},
"machine": {
"type": "t2.medium"
"type": "t2.micro"
},
"provider": "aws",
"region": "us-east-1"
"region": "us-west-1"
},
"event": {
"dataset": "aws.ec2",
Expand Down
4 changes: 4 additions & 0 deletions x-pack/metricbeat/module/aws/ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ func (m *MetricSet) createCloudWatchEvents(getMetricDataResults []cloudwatch.Met
// Note: tag values are not dedotted.
for _, tag := range tags {
events[instanceID].ModuleFields.Put("tags."+common.DeDot(*tag.Key), *tag.Value)
// add cloud.instance.name and host.name into ec2 events
if *tag.Key == "Name" {
events[instanceID].RootFields.Put("cloud.instance.name", *tag.Value)
}
}

machineType, err := instanceOutput[instanceID].InstanceType.MarshalValue()
Expand Down

0 comments on commit c1055c6

Please sign in to comment.