Skip to content

examples(gcp): add BigQuery REST API integration example#624

Open
dpacheconr wants to merge 2 commits intonewrelic:masterfrom
dpacheconr:examples/gcp-bigquery-rest-api
Open

examples(gcp): add BigQuery REST API integration example#624
dpacheconr wants to merge 2 commits intonewrelic:masterfrom
dpacheconr:examples/gcp-bigquery-rest-api

Conversation

@dpacheconr
Copy link
Copy Markdown
Contributor

Summary

  • Adds bq-rest.yml as a complementary BigQuery integration using the BigQuery REST API directly, alongside the existing bq.yml which uses the bq CLI
  • Useful for environments where the bq CLI is not available (containers, restricted hosts)
  • Uses the Flex lookup feature to chain an OAuth2 bearer token (fetched via gcloud auth application-default print-access-token) into subsequent HTTP API calls — gcloud caches the token locally so there is no network overhead on most polls
  • Updates README.md with a comparison table and separate sections for each approach

New events reported

Event type Description
bq_rest_table_stats Lists all tables in a dataset with metadata via REST
bq_rest_storage_stats Table storage stats via INFORMATION_SCHEMA query through the REST query API

Test plan

  • Set project_id and dataset_id in variable_store
  • Run gcloud auth application-default login on test host
  • Validate manually: [sudo] /opt/newrelic-infra/newrelic-integrations/bin/nri-flex --verbose --pretty --config_file bq-rest.yml
  • Confirm bq_rest_table_stats and bq_rest_storage_stats events appear in NRDB
  • Confirm existing bq.yml is unchanged and still works

Adds bq-rest.yml as a complementary approach to the existing bq.yml.
Uses the BigQuery REST API directly with an OAuth2 bearer token via
gcloud application-default credentials, making it suitable for
environments without the bq CLI (containers, restricted hosts).

Updates README to cover both approaches with a comparison table.
Adds comment explaining that gcloud caches the OAuth2 token locally
and only refreshes near expiry, so there is no network overhead on
most Flex polls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant