Skip to content

Commit

Permalink
update data.json for gcp billing (#26506) (#26542)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5667e35)
  • Loading branch information
kaiyan-sheng authored Jun 28, 2021
1 parent e159ecc commit 60590a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
13 changes: 8 additions & 5 deletions x-pack/metricbeat/module/gcp/billing/_meta/data.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"cloud.account.id": "elastic-bi",
"cloud.account.name": "elastic-bi",
"cloud.account.id": "01475F-5B1080-1137E7",
"cloud.project.id": "elastic-bi",
"cloud.project.name": "elastic-containerlib-prod",
"cloud.provider": "gcp",
"event": {
"dataset": "gcp.billing",
Expand All @@ -10,10 +11,12 @@
},
"gcp": {
"billing": {
"billing_account_id": "01475F-5B1080-1137E7",
"cost_type": "regular",
"invoice_month": "202010",
"project_id": "elastic-fin-bi",
"total": 77.897328
"invoice_month": "202106",
"project_id": "containerlib-prod-12763",
"project_name": "elastic-containerlib-prod",
"total": 4717.170681
}
},
"metricset": {
Expand Down
17 changes: 17 additions & 0 deletions x-pack/metricbeat/module/gcp/billing/billing_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,27 @@ package billing
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/gcp/metrics"
)

func TestFetch(t *testing.T) {
config := metrics.GetConfigForTest(t, "billing")
config["period"] = "24h"
config["dataset_id"] = "master_gcp"

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)
mbtest.TestMetricsetFieldsDocumented(t, metricSet, events)
}

func TestData(t *testing.T) {
config := metrics.GetConfigForTest(t, "billing")
config["period"] = "24h"
Expand Down

0 comments on commit 60590a6

Please sign in to comment.