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

[libbeat]image.id and account.id for add_cloud_metadata EC2 #12307

Merged
merged 4 commits into from
May 28, 2019
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- New `extract_array` processor. {pull}11761[11761]
- Add number of goroutines to reported metrics. {pull}12135[12135]
- Add `proxy_disable` output flag to explicitly ignore proxy environment variables. {issue}11713[11713] {pull}12243[12243]
- Processor `add_cloud_metadata` adds fields `cloud.account.id` and `cloud.image.id` for AWS EC2. {pull}12307[12307]

*Auditbeat*

Expand Down
32 changes: 17 additions & 15 deletions libbeat/docs/processors-using.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,11 @@ _AWS_
-------------------------------------------------------------------------------
{
"cloud": {
"account.id": "123456789012",
"availability_zone": "us-east-1c",
"instance_id": "i-4e123456",
"machine_type": "t2.medium",
"instance.id": "i-4e123456",
"machine.type": "t2.medium",
"image.id": "ami-abcd1234",
"provider": "aws",
"region": "us-east-1"
}
Expand All @@ -558,7 +560,7 @@ _Digital Ocean_
-------------------------------------------------------------------------------
{
"cloud": {
"instance_id": "1234567",
"instance.id": "1234567",
"provider": "digitalocean",
"region": "nyc2"
}
Expand All @@ -572,9 +574,9 @@ _GCP_
{
"cloud": {
"availability_zone": "us-east1-b",
"instance_id": "1234556778987654321",
"machine_type": "f1-micro",
"project_id": "my-dev",
"instance.id": "1234556778987654321",
"machine.type": "f1-micro",
"project.id": "my-dev",
"provider": "gcp"
}
}
Expand All @@ -587,7 +589,7 @@ _Tencent Cloud_
{
"cloud": {
"availability_zone": "gz-azone2",
"instance_id": "ins-qcloudv5",
"instance.id": "ins-qcloudv5",
"provider": "qcloud",
"region": "china-south-gz"
}
Expand All @@ -604,7 +606,7 @@ ECS instance.
{
"cloud": {
"availability_zone": "cn-shenzhen",
"instance_id": "i-wz9g2hqiikg0aliyun2b",
"instance.id": "i-wz9g2hqiikg0aliyun2b",
"provider": "ecs",
"region": "cn-shenzhen-a"
}
Expand All @@ -618,9 +620,9 @@ _Azure Virtual Machine_
{
"cloud": {
"provider": "az",
"instance_id": "04ab04c3-63de-4709-a9f9-9ab8c0411d5e",
"instance_name": "test-az-vm",
"machine_type": "Standard_D3_v2",
"instance.id": "04ab04c3-63de-4709-a9f9-9ab8c0411d5e",
"instance.name": "test-az-vm",
"machine.type": "Standard_D3_v2",
"region": "eastus2"
}
}
Expand All @@ -632,11 +634,11 @@ _Openstack Nova_
-------------------------------------------------------------------------------
{
"cloud": {
"provider": "openstack",
"instance_name": "test-998d932195.mycloud.tld",
"instance.name": "test-998d932195.mycloud.tld",
"instance.id": "i-00011a84",
"availability_zone": "xxxx-az-c",
"instance_id": "i-00011a84",
"machine_type": "m2.large"
"provider": "openstack",
"machine.type": "m2.large"
}
}
-------------------------------------------------------------------------------
Expand Down
13 changes: 6 additions & 7 deletions libbeat/processors/add_cloud_metadata/provider_aws_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ import (
c "github.com/elastic/beats/libbeat/common/schema/mapstriface"
)

const ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document"

// AWS EC2 Metadata Service
func newEc2MetadataFetcher(config *common.Config) (*metadataFetcher, error) {
ec2InstanceIdentityURI := "/2014-02-25/dynamic/instance-identity/document"
ec2Schema := func(m map[string]interface{}) common.MapStr {
out, _ := s.Schema{
"instance": s.Object{
"id": c.Str("instanceId"),
},
"machine": s.Object{
"type": c.Str("instanceType"),
},
"instance": s.Object{"id": c.Str("instanceId")},
"machine": s.Object{"type": c.Str("instanceType")},
"region": c.Str("region"),
"availability_zone": c.Str("availabilityZone"),
"account": s.Object{"id": c.Str("accountId")},
"image": s.Object{"id": c.Str("imageId")},
}.Apply(m)
return out
}
Expand Down
Loading