-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Metricbeat] Change Account ID to Project ID in gcp.billing
module
#26412
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
Pinging @elastic/integrations (Team:Integrations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @legoguy1000 thank you for your contribution!! Do you know if we can get the account ID and account name in GCP from the given project ID? I would like to report both account ID/Name and project ID in gcp.billing
.
@kaiyan-sheng based on this, https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#data-schema, I made additional changes to the query to pull the account info. I don't have a GCP account with any actual billing so I don't have a good way to validate the query besides just looking at the schema in the above link. I was able to add the |
@kaiyan-sheng can you run the tests when you get a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change. I tested it locally and here is what I saw:
2021-06-23T15:33:35.456-0600 ERROR [billing] billing/billing.go:242 bigquery Wait failed: googleapi: Error 400: SELECT list expression references column billing_account_id which is neither grouped nor aggregated at [6:33], invalidQuery
2021-06-23T15:54:33.736-0600 ERROR [billing] billing/billing.go:241 bigquery Wait failed: googleapi: Error 400: SELECT list expression references column cost_type which is neither grouped nor aggregated at [6:33], invalidQuery
I will look into it a bit more tomorrow :)
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, adding GROUP BY
and ORDER BY
fixed the issue:
query := fmt.Sprintf(`
SELECT
invoice.month,
project.id,
project.name,
billing_account_id,
cost_type,
(SUM(CAST(cost * 1000000 AS int64))
+ SUM(IFNULL((SELECT SUM(CAST(c.amount * 1000000 as int64)) FROM UNNEST(credits) c), 0))) / 1000000
AS total_exact
FROM %s
WHERE project.id IS NOT NULL
AND invoice.month = '%s'
AND cost_type = '%s'
GROUP BY 1, 2, 3, 4, 5
ORDER BY 1 ASC, 2 ASC, 3 ASC, 4 ASC, 5 ASC;`, tableMeta.tableFullID, month, costType)
@kaiyan-sheng Query fixed. Should be good for CI tests now. |
/test |
@kaiyan-sheng Looks good to merge now. |
* master: (32 commits) [Metricbeat] Change Account ID to Project ID in `gcp.billing` module (elastic#26412) update libbeat fields.ecs.yml file and ecsVersion to 1.10.0 (elastic#26121) [Filebeat] Update AWS ELB ingest pipeline (elastic#26441) [FIlebeat] add strict_date_optional_time_nanos date format to PanOS module (elastic#26158) Fix the irregular and typo on prometheus module. (elastic#25726) [Filebeat] Parse additonal debug data fields for Okta module (elastic#25818) fix: update MSSQL Server linux image's Docker registry (elastic#26440) Update indexing.go godocs (elastic#26408) Do not close filestream harvester if an unexpected error is returned when close.on_state_change.* is enabled (elastic#26411) Add support for copytruncate method when rotating input logs with an external tool in `filestream` input (elastic#23457) Allow fields with ip_range datatype (elastic#26444) Add Anomali ThreatStream support to threatintel module (elastic#26350) fix: use the right param type (elastic#26469) [Automation] Update elastic stack version to 8.0.0-7640093f for testing (elastic#26460) Set SM Filebeat modules as GA (elastic#26226) Fix rfc5464 date parsing in the syslog input (elastic#26419) Add linked account information into billing metricset (elastic#26285) [Filebeat] Update HA Proxy log grok patterns (elastic#25835) disable metricbeat logstash test_node_stats (elastic#26436) chore: pass BEAT_VERSION when running E2E tests (elastic#26291) ...
What does this PR do?
Currently the GCP Project ID is being ingested as
cloud.account.id
instead ofcloud.project.id
. This PR fixes that.Why is it important?
See above
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs