grafana / dbt_leaner_query

MIT License
23 stars 3 forks source link

LeanerQuery dbt Package

This is a dbt package built to help teams that use BigQuery understand their costs associated with dbt and general use.

This package uses BigQuery Audit Log data and assumes that a log sink is set up to export the logs into tables in a BigQuery dataset. If you are unfamiliar with how to accomplish this, visit this Google cloud resource.

This package assumes that the user(s) executing the processes have read access to the bigquery log dataset referenced above and write access to the dataset where leaner_query is creating/updating objects.

The package contains a lot of variable values to determine costs, aggregation, and scoring. You will want to override/specify some of these values in your dbt_project.yml file as your details and use cases are undoubtedly different than ours. More details in the variables section.

This dbt package aims to provide the following details for data teams who are using BigQuery:

Quick Links

Getting Started

leaner_query_prod_dataset_names: ['marts','reports'] leaner_query_stage_dataset_names: ['staging_models']

leaner_query_custom_clients: [ {'user_agent': 'agent_string', 'principal_email':'username', 'client_name':'Custom Client 1'}, {'user_agent': 'agent_string', 'principal_email':'different_username', 'client_name':'Custom Client 2'}, ]

leaner_query_custom_egress_emails: [ 'egress_sa@your-project.iam.gserviceaccount.com', 'another_sa@your-project.iam.gserviceaccount.com', ]

- Optionally update your dbt_project.yml file to override the dataset where the leaner_query models will be built (defaults to `leaner-query`):
```YML
leaner_query:
    +schema: leaner_query_output

Models

The package outputs a dimensional model that allows users to build upon for custom analysis and reporting. This dimensional model contains:

Reports

Note: Reports can be disabled by changing the leaner_query_enable_reports variable value to false.

Visualization

Grafana Dashboarding Template

We have included a template for our Grafana Dashboard that help to track our BQ and dbt costs. You can find the raw JSON in grafana_dashboard_template.json. You can easily import this dashboard into any Grafana instance and immediately start visualizing your data - assuming you have the BigQuery Datasource configured.