• This repository has been archived on 11/Dec/2022
  • Stars
    star
    242
  • Rank 167,048 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Google BigQuery Datasource Plugin for Grafana. (NO LONGER MAINTAINED)

We have retired the DoiT International BigQuery DataSource plugin for Grafana, ceased all development, and put maintenance on indefinite hold. We recommend you migrate to the official Google BigQuery data source maintained by Grafana.


GitHub stars GitHub forks Automated Release Notes by gren

BigQuery DataSource for Grafana

A production-ready BigQuery DataSource plugin that provides support for BigQuery as a backend database.

Quick Start

There are multiple ways to install bigquery-grafana. See INSTALL for more information.

Features:

  • Query setup
  • Raw SQL editor
  • Query builder
  • Macros support
  • Additional functions
  • Table view
  • Annotations
  • BQ queries in variables
  • Sharded tables (tablename_YYYYMMDD)
  • Partitioned Tables
  • Granular slot allocation (Running queries in a project with flat-rate pricing)

Plugin Demo:

plugin demo

Adding the DataSource to Grafana

  1. Open the side menu by clicking the Grafana icon in the top header.
  2. In the side menu under Dashboards you should find a link named Data Sources.
  3. Click the + Add data source button in the top header.
  4. Select BigQuery from the Type dropdown.
  5. Upload or paste in the Service Account Key file. See below for steps on how to create a Service Account Key file.

NOTE: If you're not seeing the Data Sources link in your side menu it means that your current user does not have the Admin role for the current organization.

Name Description
Name The datasource name. This is how you refer to the datasource in panels & queries.
Default Default datasource means that it will be pre-selected for new panels.
Service Account Key Service Account Key File for a GCP Project. Instructions below on how to create it.

Set query priority

You can now set query priority "INTERACTIVE" or "BATCH" per datasouce

Example of Provisioning a File

You can manage DataSource via provisioning system. See the example below of a configuration file.

apiVersion: 1

datasources:
- name: <Datasource Name>
  type: doitintl-bigquery-datasource
  access: proxy
  isDefault: true
  jsonData:
       authenticationType: jwt
       clientEmail: <Service Account Email>
       defaultProject: <Default Project Name>
       tokenUri: https://oauth2.googleapis.com/token
  secureJsonData:
       privateKey: |
          -----BEGIN PRIVATE KEY-----
           <Content of the Private Key>
          -----END PRIVATE KEY-----
  version: 2
  readOnly: false

Authentication

There are two ways to authenticate the BigQuery plugin - either by uploading a Google JWT file, or by automatically retrieving credentials from Google's metadata server. The latter is only available when running Grafana on a GCE virtual machine.

Using a Google Service Account Key File

To authenticate with the BigQuery API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you can give the service account permissions in each project or create one datasource per GCP Project.

Enable APIs

Go to BigQuery API and Enable the API:

Enable GCP APIs

Create a GCP Service Account for a Project

  1. Navigate to the APIs & Services Credentials page.

  2. Click on Create credentials and choose Service account key.

  3. On the Create service account key page, choose key type JSON. Then in the Service Account dropdown, choose the New service account option:

  4. Some new fields will appear. Fill in a name for the service account in the Service account name field and then choose the BigQuery Data Viewer and BigQuery Job User roles from the Role dropdown:

  5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your BigQuery data.

  6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.

  7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!

Using GCE Default Service Account

If Grafana is running on a Google Compute Engine (GCE) virtual machine, it is possible for Grafana to automatically retrieve default credentials from the metadata server. This has the advantage of not needing to generate a private key file for the service account and also not having to upload the file to Grafana. However for this to work, there are a few preconditions that need to be met.

  1. First of all, you need to create a Service Account that can be used by the GCE virtual machine. See detailed instructions on how to do that here.
  2. Make sure the GCE virtual machine instance is being run as the service account that you just created. See instructions here.
  3. Allow access to the BigQuery API scope. See instructions here.

Read more about creating and enabling service accounts for GCE VM instances here.

Using the Query Builder

The query builder provides a simple yet a user-friendly interface to help you quickly compose a query. The builder enables you to define the basic parts of your query, The common ones are:

  1. The table you want to query from

  2. The time field and metric field

  3. WHERE clause - Either use one of the pre-defined macros, to speed your writing time, or set up your own expression. Existing supported Macros are:

    a. Macro $__timeFiler with last 7 days example:

  WHERE `createDate` BETWEEN TIMESTAMP_MILLIS (1592147699012) AND TIMESTAMP_MILLIS (1592752499012) AND _PARTITIONTIME >= '2020-06-14 18:14:59' AND _PARTITIONTIME < '2020-06-21 18:14:59'

b. Macro $__timeFrom with last 7 days example:

  WHERE `createDate` > TIMESTAMP_MILLIS (1592223758609)  AND _PARTITIONTIME >= '2020-06-15 15:22:38' AND _PARTITIONTIME < '2020-06-22 15:22:38'

c. Macro $__timeTo with last 7 days example:

  WHERE `createDate` < TIMESTAMP_MILLIS (1592828659681)  AND _PARTITIONTIME >= '2020-06-15 15:24:19' AND _PARTITIONTIME < '2020-06-22 15:24:19'

You can now use timeFilter macro in raw sql mode

  1. GROUP BY option - You can use a pre-defined macro or use one of the fields from your query a. time ($__interval,none)
  2. ORDER BY option

Note: If your processing location is not the Default US one set your location from the processing Location drop-down at the top right bottom of the query builder

Troubleshooting

Viewing your Query

  1. Use The Query Inspector located at the top of the query builder
  2. The query Inspector enables you to see the clean query and troubleshoot SQL errors The Query builder comes with a set of defaults which are control from the top of the Query Builder

Build

The build works with Yarn:

Development Build

yarn run build:dev

Production Build

yarn run build:prod

Tests can be run with Jest:

yarn run test

Contributing

See the CONTRIBUTING file.

License

See the LICENSE file.

More Repositories

1

kube-no-trouble

Easily check your clusters for use of deprecated APIs
Go
3,126
star
2

kubeip

Assign static public IPs to Kubernetes nodes (GKE, EKS)
Go
391
star
3

gcpinstances.info

GCPinstances.info source code
Python
173
star
4

secrets-init

minimalistic init system for containers with AWS/GCP secrets support
Go
161
star
5

kube-secrets-init

Kubernetes mutating webhook for `secrets-init` injection
Go
148
star
6

zorya

Google Cloud Instance Scheduler helping to reduce costs by 60% on average for non-production environments.
JavaScript
141
star
7

secure-gcp-reference

Best practice example for secure and compliant Google Cloud Platform infrastructure
99
star
8

gtoken

Securely access AWS services from GKE cluster
Go
73
star
9

gSlack

Get Slack notifications from Google Cloud Platform
JavaScript
72
star
10

iris3

An upgraded and improved version of the Iris automatic GCP-labeling project
Python
71
star
11

gpu-finder

Python
69
star
12

SafeScrub

Safely delete unwanted resources in a GCP project, clearing clutter and saving money.
Shell
68
star
13

bigquery-optimization-queries

Queries to assist with BigQuery cost and performance.
Python
61
star
14

banias

Opinionated serverless event analytics pipeline
Go
43
star
15

janus

Janus is a simple way to assume AWS Role with Google Cloud Service Account
Python
40
star
16

ClusterCloner

Clone Kubernetes clusters (VM infrastructure, not K8s objects) to/from AWS EKS, GCP GKE, and Azure EKS.
Go
33
star
17

doit-composer-airflow-training

Getting started with Apache Airflow on Cloud Composer
Python
28
star
18

gke-fundamentals-workshop

Shell
25
star
19

bqtop

Visualizing BigQuery query jobs with Cloud Functions, Firebase andΒ Pub/Sub
JavaScript
25
star
20

CloudBlaster

Kotlin
22
star
21

Cloud-Tasks-In-Process-Emulator

Google doesn't offer an emulator for the Cloud Tasks API, as it does for Datastore or PubSub. This project answers that need with a single short Python module intended to be copied to your codebase.
Python
20
star
22

AWSlack

Get Slack notifications on AWS CloudWatch events
JavaScript
19
star
23

gcp-monitoring-metric-exporter

Python
18
star
24

workload-identity-analyzer

A tool to analyze a workload running in GKE and make sure that Workload Identity is configured properly
Python
16
star
25

doit-easily-marketplace

Python
12
star
26

dataflow-kafka-to-bq

Dataflow template which read data from Kafka (Support SSL), transform, and outputs the resulting records to BigQuery
Java
12
star
27

cloud-catalog

Extract categories and services (as unified JSON) for major public cloud services.
Python
11
star
28

gcs-stats

Easily analyze the size of Google Cloud Storage buckets regardless of their size
JavaScript
10
star
29

terraform-iac-demo

GitOps demo of Terraform infrastructure as code (IaC)
HCL
9
star
30

aws-eks-sample-templates

The repository contains the sample templates to get started with AWS EKS quickly
9
star
31

secrets-consumer-webhook

Kubernetes mutation webhook for secrets-consumer-env - Automatically inject secrets to Pod
Go
9
star
32

gke-https-redirect

Demonstration how to use the newly introduced https redirect support in native GKE ingress resources.
9
star
33

gcp-discover-orphaned-firewall-rules

Find orphaned firewall rules that are not applied to any VM instances in a shared VPC
Go
8
star
34

esop

Employee Stock Option Plan
8
star
35

eks-spot-to-ondemand-fallback

7
star
36

terraform-bq-scheduled-queries

This is a demo project to use Terraform to manage BigQuery scheduled queries with Cloud Build CI/CD
HCL
7
star
37

bi-engine-statistics

a opinionated bi engine statistics dashboard for dashboard
LookML
7
star
38

ignite-gke

Running Apache Ignite on GKE the "right" way
Java
6
star
39

bq-snitch-app

Get visibility into expensive Google BigQuery queries on Slack
Python
6
star
40

DoiT-AdminPulse-for-Workspace

A tool for Workspace administrators to review their security posture and inventory the admin SDK.
JavaScript
6
star
41

terraform-gcp-templates

Generic Terraform GCP templates
HCL
5
star
42

validating-admission-policy-playground

5
star
43

azure-instances.info

HTML
5
star
44

QuickQuickstarts

The simplest quickstart scripts for running multiple web backend infrastructures in AWS and GCP.
Shell
5
star
45

dataflow-bigquery-schema-migrator-insert

Dataflow Bigquery Schema Migrator Insert
Java
5
star
46

spotzero

Update EC2 Auto Scaling groups in AWS account to use Spot instances.
Go
4
star
47

galactus

A tool for detecting unused Service Accounts and Service Account Keys on GCP
Python
4
star
48

gcp-alerting-cis-benchmarks

Configuration instructions for Cloud Monitoring alerts on Google Cloud Platform for additional security based on CIS benchmarks
4
star
49

private_cloud_sql

4
star
50

intercloud-throughput

Python
4
star
51

secrets-consumer-env

Consume secrets securely from AWS, GCP and Hashicorp Vault secret managers
Go
3
star
52

ec2-auto-tag

Python
3
star
53

elasticsearch-gke

Blueprint for creating production-grade ElasticSearch deployments with Elastic K8s Operator
Makefile
3
star
54

ferent

Clojure
3
star
55

calculate-cloudfront-aos

Calculate CloudFront Average Object Size (AOS) using Cost Explorer API
Python
3
star
56

cre-playbooks

A collection of playbooks to help CREs solve problems more efficiently
3
star
57

docs-gitbook-cmp

ARCHIVED: GitBook repository for the DoiT Cloud Management Platform (CMP) User Documentation
Shell
3
star
58

docops

Common resources for doing DocOps at DoiT
Python
3
star
59

terraform-provider-doit-console

Terraform provider for DoiT API platform
Go
3
star
60

doit-eks-lens-helm-chart

Smarty
3
star
61

docops-devcontainer

DocOps devcontainer
2
star
62

next23-genai-demo

Jupyter Notebook
2
star
63

gke-ssh

HCL
2
star
64

platform-iac

DoiT platform infrastructure as a code templates
HCL
2
star
65

cloud-run-go-boilerplate

Go
2
star
66

gceinstances

Inspired by ec2instances.info, this is a summary page for Google Compute Engine instances
HTML
2
star
67

docops-python

DoiT International DocOps Python library and CLI program
Shell
2
star
68

mysql-57-eol

Documents to help guide customers through MySQL 5.7 End of life
2
star
69

tf-fundamentals-workshop-101

Basic workshop on the topic of Terraform in the context of AWS
HCL
2
star
70

looker-cph-event

LookML
1
star
71

robust-multicloud

Kotlin
1
star
72

help

DoiT International Help Center and product documentation
JavaScript
1
star
73

secret-manager-nodejs-example

JavaScript
1
star
74

assembly-pipeline

Shell
1
star
75

cloudbuild-demo

JavaScript
1
star
76

demo-gke-pubsub-consumer

JavaScript
1
star
77

clojure-exercises

Clojure
1
star
78

poc-gcp-nextflow

Nextflow + GCP + LifeSciencesAPI + Compute Engine + NextflowTower + Workflows
1
star
79

app-engine-firebase-identity

BYO Identity through Firebase
Python
1
star
80

dynamodb-lens

Python
1
star
81

cloudrun-cloudsql-psc

Accessing CloudSQL with Private Service Connect enabled from Cloud Run
1
star
82

zen-dog

Tool to sync crucial zendesk configuration from code
1
star
83

gcp-auto-tag

Python
1
star
84

locust-demo

Python
1
star
85

gke-node-autoscheduler-poc

HCL
1
star
86

eks-lens-agent

Go
1
star
87

gcp-qms

Quota Monitoring Solution support files for Google Cloud Platform
Shell
1
star
88

avoxi-workshop-public

Jupyter Notebook
1
star
89

developer-envs

HCL
1
star
90

simple-cloud-run

Sometimes it's amazing how simple Google Cloud can be - this time Cloud Run
Go
1
star
91

terraform-provider-doit

Terraform provider for DoiT API platform
Go
1
star
92

next24-genai-demo

Gen AI Demo for Google Next'24. This is a RAG system with Agents to retrieve project specific cost and combine it with DoiT blog posts to deliver a analysis on how to reduce cost.
Jupyter Notebook
1
star
93

aws-dms-to-hudi

Example AWS DMS ingestion pipeline to Apache Hudi tables in S3
Python
1
star
94

bigquery-list-tables-org-wide

A script that will list all tables (and potentially relevant metadata) across your whole Google Cloud organisation.
Python
1
star
95

LLM-Liftoff-Bedrock-Workshop

Python
1
star
96

ticket-review

An app for performing ticket reviews.
HCL
1
star
97

aws-help

Help Docs for DoIT AWS Customers
1
star