From 82836dab2470db6a0821462eac08d52c03c23042 Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Fri, 25 Jun 2021 10:25:03 -0600 Subject: [PATCH] update data.json for gcp billing --- .../module/gcp/billing/_meta/data.json | 13 ++++++++----- .../gcp/billing/billing_integration_test.go | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/x-pack/metricbeat/module/gcp/billing/_meta/data.json b/x-pack/metricbeat/module/gcp/billing/_meta/data.json index a9b52f82898..efbb1088bec 100644 --- a/x-pack/metricbeat/module/gcp/billing/_meta/data.json +++ b/x-pack/metricbeat/module/gcp/billing/_meta/data.json @@ -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", @@ -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": { diff --git a/x-pack/metricbeat/module/gcp/billing/billing_integration_test.go b/x-pack/metricbeat/module/gcp/billing/billing_integration_test.go index 9c006fb30cc..7da63d3dc64 100644 --- a/x-pack/metricbeat/module/gcp/billing/billing_integration_test.go +++ b/x-pack/metricbeat/module/gcp/billing/billing_integration_test.go @@ -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"