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

Move s3_daily_storage and s3_request metricsets to use cloudwatch input #21703

Merged
merged 3 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -746,6 +746,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Move Prometheus query & remote_write to GA. {pull}21507[21507]
- Expand unsupported option from namespace to metrics in the azure module. {pull}21486[21486]
- Map cloud data filed `cloud.account.id` to azure subscription. {pull}21483[21483] {issue}21381[21381]
- Move s3_daily_storage and s3_request metricsets to use cloudwatch input. {pull}21703[21703]

*Packetbeat*

Expand Down
1 change: 1 addition & 0 deletions metricbeat/docs/modules/aws/s3_daily_storage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This file is generated! See scripts/mage/docs_collector.go

include::../../../../x-pack/metricbeat/module/aws/s3_daily_storage/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

==== Fields

Expand Down
1 change: 1 addition & 0 deletions metricbeat/docs/modules/aws/s3_request.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This file is generated! See scripts/mage/docs_collector.go

include::../../../../x-pack/metricbeat/module/aws/s3_request/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

==== Fields

Expand Down
2 changes: 0 additions & 2 deletions x-pack/metricbeat/include/list.go

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

2 changes: 2 additions & 0 deletions x-pack/metricbeat/module/aws/module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metricsets:
- ebs
- usage
- sns
- s3_daily_storage
- s3_request
- lambda
- dynamodb
- vpn
Expand Down
1 change: 1 addition & 0 deletions x-pack/metricbeat/module/aws/mtest/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func GetConfigForTest(t *testing.T, metricSetName string, period string) map[str
"access_key_id": accessKeyID,
"secret_access_key": secretAccessKey,
"default_region": defaultRegion,
"latency": "5m",
// You can specify which region to run test on by using regions variable
// "regions": []string{"us-east-1"},
}
Expand Down
27 changes: 14 additions & 13 deletions x-pack/metricbeat/module/aws/s3_daily_storage/_meta/data.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"aws": {
"s3": {
"bucket": {
"name": "test-s3-ks-2"
}
"cloudwatch": {
"namespace": "AWS/S3"
},
"dimensions": {
"BucketName": "filebeat-aws-elb-test",
"StorageType": "AllStorageTypes"
},
"s3_daily_storage": {
"bucket": {
"size": {
"bytes": 207372
"s3": {
"metrics": {
"NumberOfObjects": {
"avg": 57828
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is rename not being applied here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's applied when I run metricbeat for testing but not applied when I tried to create the event for data.json. Is there any way I can make the rename processor work with TestData function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, maybe processors are not initialized on testing, if that is the case we should fix that, but not on this PR. Could you please open an issue about that?

But interestingly in the iis module there is a rename that seems to be applied 🤔

- rename:
ignore_missing: true
fields:
- from: "iis.website.instance"
to: "iis.website.name"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. @narph I saw you generated the data.json file for iis website. Does the field iis.website.name generated automatically by TestData function? For my case, TestData function ignores the rename processor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am setting the iis.website.name using the rename processor inside the manifest.yml file

}
},
"number_of_objects": 128
}
}
},
"cloud": {
"account": {
"id": "627959692251",
"name": "elastic-test"
"id": "428152502467",
"name": "elastic-beats"
},
"provider": "aws",
"region": "ap-southeast-1"
"region": "eu-central-1"
},
"event": {
"dataset": "aws.s3_daily_storage",
Expand Down
21 changes: 0 additions & 21 deletions x-pack/metricbeat/module/aws/s3_daily_storage/data.go

This file was deleted.

22 changes: 22 additions & 0 deletions x-pack/metricbeat/module/aws/s3_daily_storage/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
default: true
input:
module: aws
metricset: cloudwatch
defaults:
metrics:
- namespace: AWS/S3
statistic: ["Average"]
name:
- BucketSizeBytes
- NumberOfObjects

processors:
- rename:
ignore_missing: true
fields:
- from: "aws.s3.metrics.NumberOfObjects.avg"
to: "aws.s3_daily_storage.number_of_objects"
- from: "aws.s3.metrics.BucketSizeBytes.avg"
to: "aws.s3_daily_storage.bucket.size.bytes"
- from: "aws.dimensions.BucketName"
to: "aws.s3.bucket.name"
219 changes: 0 additions & 219 deletions x-pack/metricbeat/module/aws/s3_daily_storage/s3_daily_storage.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,13 @@ package s3_daily_storage
import (
"testing"

"github.com/stretchr/testify/assert"

mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
"github.com/elastic/beats/v7/x-pack/metricbeat/module/aws/mtest"
)

func TestFetch(t *testing.T) {
config := mtest.GetConfigForTest(t, "s3_daily_storage", "86400s")

metricSet := mbtest.NewReportingMetricSetV2Error(t, config)
events, errs := mbtest.ReportingFetchV2Error(metricSet)
if len(errs) > 0 {
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs)
}

assert.NotEmpty(t, events)

for _, event := range events {
// RootField
mtest.CheckEventField("service.name", "string", event, t)
mtest.CheckEventField("cloud.region", "string", event, t)

// MetricSetField
mtest.CheckEventField("bucket.name", "string", event, t)
mtest.CheckEventField("bucket.size.bytes", "float", event, t)
mtest.CheckEventField("number_of_objects", "float", event, t)
}
}

func TestData(t *testing.T) {
config := mtest.GetConfigForTest(t, "s3_daily_storage", "86400s")

metricSet := mbtest.NewReportingMetricSetV2Error(t, config)
if err := mbtest.WriteEventsReporterV2Error(metricSet, t, "/"); err != nil {
t.Fatal("write", err)
}
metricSet := mbtest.NewFetcher(t, config)
metricSet.WriteEvents(t, "/")
}
Loading