Skip to content

Commit 5bde9d0

Browse files
author
Andrew Stucki
authored
Add cloud.service.name to add_cloud_metadata (#24993)
* Add cloud.service.name to add_cloud_metadata * update changelog
1 parent 9625db6 commit 5bde9d0

15 files changed

Lines changed: 63 additions & 4 deletions

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
600600
- Added new `rate_limit` processor for enforcing rate limits on event throughput. {pull}22883[22883]
601601
- Allow node/namespace metadata to be disabled on kubernetes metagen and ensure add_kubernetes_metadata honors host {pull}23012[23012]
602602
- Add `wineventlog` schema to `decode_xml` processor. {issue}23910[23910] {pull}24726[24726]
603+
- Add new ECS 1.9 field `cloud.service.name` to `add_cloud_metadata` processor. {pull}24993[24993]
603604

604605
*Auditbeat*
605606

libbeat/processors/add_cloud_metadata/provider_alibaba_cloud.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ var alibabaCloudMetadataFetcher = provider{
3333
ecsMetadataZoneURI := "/latest/meta-data/zone-id"
3434

3535
ecsSchema := func(m map[string]interface{}) common.MapStr {
36+
m["service"] = common.MapStr{
37+
"name": "ECS",
38+
}
3639
return common.MapStr(m)
3740
}
3841

libbeat/processors/add_cloud_metadata/provider_alibaba_cloud_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ func TestRetrieveAlibabaCloudMetadata(t *testing.T) {
8181
},
8282
"region": "cn-shenzhen",
8383
"availability_zone": "cn-shenzhen-a",
84+
"service": common.MapStr{
85+
"name": "ECS",
86+
},
8487
},
8588
}
8689
assert.Equal(t, expected, actual.Fields)

libbeat/processors/add_cloud_metadata/provider_aws_ec2.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ var ec2MetadataFetcher = provider{
3333

3434
Create: func(_ string, config *common.Config) (metadataFetcher, error) {
3535
ec2Schema := func(m map[string]interface{}) common.MapStr {
36+
m["serviceName"] = "EC2"
3637
out, _ := s.Schema{
3738
"instance": s.Object{"id": c.Str("instanceId")},
3839
"machine": s.Object{"type": c.Str("instanceType")},
3940
"region": c.Str("region"),
4041
"availability_zone": c.Str("availabilityZone"),
41-
"account": s.Object{"id": c.Str("accountId")},
42-
"image": s.Object{"id": c.Str("imageId")},
42+
"service": s.Object{
43+
"name": c.Str("serviceName"),
44+
},
45+
"account": s.Object{"id": c.Str("accountId")},
46+
"image": s.Object{"id": c.Str("imageId")},
4347
}.Apply(m)
4448
return out
4549
}

libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) {
7272
"imageId" : "%s",
7373
"instanceType" : "%s",
7474
"devpayProductCodes" : null,
75-
"privateIp" : "10.0.0.1",
75+
"privateIp" : "10.0.0.1",
7676
"version" : "2010-08-31",
7777
"billingProducts" : null,
7878
"pendingTime" : "2016-09-20T15:43:02Z",
@@ -114,6 +114,9 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) {
114114
"image": common.MapStr{"id": imageIDDoc1},
115115
"region": regionDoc1,
116116
"availability_zone": availabilityZoneDoc1,
117+
"service": common.MapStr{
118+
"name": "EC2",
119+
},
117120
},
118121
},
119122
},
@@ -154,6 +157,9 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) {
154157
"image": common.MapStr{"id": imageIDDoc1},
155158
"region": regionDoc1,
156159
"availability_zone": availabilityZoneDoc1,
160+
"service": common.MapStr{
161+
"name": "EC2",
162+
},
157163
},
158164
},
159165
},
@@ -172,6 +178,9 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) {
172178
"image": common.MapStr{"id": imageIDDoc1},
173179
"region": regionDoc1,
174180
"availability_zone": availabilityZoneDoc1,
181+
"service": common.MapStr{
182+
"name": "EC2",
183+
},
175184
},
176185
},
177186
},
@@ -194,6 +203,9 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) {
194203
"image": common.MapStr{"id": imageIDDoc1},
195204
"region": regionDoc1,
196205
"availability_zone": availabilityZoneDoc1,
206+
"service": common.MapStr{
207+
"name": "EC2",
208+
},
197209
},
198210
},
199211
},
@@ -215,6 +227,9 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) {
215227
"image": common.MapStr{"id": imageIDDoc1},
216228
"region": regionDoc1,
217229
"availability_zone": availabilityZoneDoc1,
230+
"service": common.MapStr{
231+
"name": "EC2",
232+
},
218233
},
219234
},
220235
},

libbeat/processors/add_cloud_metadata/provider_azure_vm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var azureVMMetadataFetcher = provider{
3333
azMetadataURI := "/metadata/instance/compute?api-version=2017-04-02"
3434
azHeaders := map[string]string{"Metadata": "true"}
3535
azSchema := func(m map[string]interface{}) common.MapStr {
36+
m["serviceName"] = "Virtual Machines"
3637
out, _ := s.Schema{
3738
"account": s.Object{
3839
"id": c.Str("subscriptionId"),
@@ -44,6 +45,9 @@ var azureVMMetadataFetcher = provider{
4445
"machine": s.Object{
4546
"type": c.Str("vmSize"),
4647
},
48+
"service": s.Object{
49+
"name": c.Str("serviceName"),
50+
},
4751
"region": c.Str("location"),
4852
}.Apply(m)
4953
return out

libbeat/processors/add_cloud_metadata/provider_azure_vm_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ func TestRetrieveAzureMetadata(t *testing.T) {
9191
"account": common.MapStr{
9292
"id": "5tfb04c3-63de-4709-a9f9-9ab8c0411d5e",
9393
},
94+
"service": common.MapStr{
95+
"name": "Virtual Machines",
96+
},
9497
"region": "eastus2",
9598
},
9699
}

libbeat/processors/add_cloud_metadata/provider_digital_ocean.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ var doMetadataFetcher = provider{
3131

3232
Create: func(provider string, config *common.Config) (metadataFetcher, error) {
3333
doSchema := func(m map[string]interface{}) common.MapStr {
34+
m["serviceName"] = "Droplets"
3435
out, _ := s.Schema{
3536
"instance": s.Object{
3637
"id": c.StrFromNum("droplet_id"),
3738
},
3839
"region": c.Str("region"),
40+
"service": s.Object{
41+
"name": c.Str("serviceName"),
42+
},
3943
}.Apply(m)
4044
return out
4145
}

libbeat/processors/add_cloud_metadata/provider_digital_ocean_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ func TestRetrieveDigitalOceanMetadata(t *testing.T) {
117117
"instance": common.MapStr{
118118
"id": "1111111",
119119
},
120+
"service": common.MapStr{
121+
"name": "Droplets",
122+
},
120123
"region": "nyc3",
121124
},
122125
}

libbeat/processors/add_cloud_metadata/provider_google_gce.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ var gceMetadataFetcher = provider{
3535
gceMetadataURI := "/computeMetadata/v1/?recursive=true&alt=json"
3636
gceHeaders := map[string]string{"Metadata-Flavor": "Google"}
3737
gceSchema := func(m map[string]interface{}) common.MapStr {
38-
out := common.MapStr{}
38+
out := common.MapStr{
39+
"service": common.MapStr{
40+
"name": "GCE",
41+
},
42+
}
3943

4044
trimLeadingPath := func(key string) {
4145
v, err := out.GetValue(key)

0 commit comments

Comments
 (0)