doitintl / bigquery-grafana

Google BigQuery Datasource Plugin for Grafana. (NO LONGER MAINTAINED)
https://www.doit-intl.com/labs/
MIT License
242 stars 76 forks source link

Example of Provisioning a File #191

Closed MassyB closed 4 years ago

MassyB commented 4 years ago

Hello ! First of all, thank you very much for the plugin :) I have some issues with the format of the provisioning file. I have some service account file that looks like this

{
  "type": "service_account",
  "project_id": "my-project",
  "private_key_id": "XXXXX_my_private_key_id_XXXXXXX",
  "private_key": "-----BEGIN PRIVATE KEY-----\nXXXXXXX_my_private_key___\nXXXXX_another_line_here_XXXXX\nXXXXXX_final_line_XXXXXX==\n-----END PRIVATE KEY-----\n",
  "client_email": "my-project@company.iam.gserviceaccount.com",
  "client_id": "123456",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://accounts.google.com/o/oauth2/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/my-project%40company.iam.gserviceaccount.com"
}

And the provisioning file that I put in /etc/grafana/provisioning/datasources/all.yaml Which looks like this

apiVersion: 1

# list of datasources to insert/update depending
# what's available in the database
datasources:
  # <string, required> name of the datasource. Required
- name: bigquery-project
  type: doitintl-bigquery-datasource
  access: proxy
  isDefault: true
  jsonData:
  authenticationType: jwt
  clientEmail: my-project@company.iam.gserviceaccount.com
  defaultProject: my-default-project
  tokenUri: https://accounts.google.com/o/oauth2/token
  secureJsonData:
  privateKey: "-----BEGIN PRIVATE KEY-----\nXXXXXXX_my_private_key___\nXXXXX_another_line_here_XXXXX\nXXXXXX_final_line_XXXXXX==\n-----END PRIVATE KEY-----\n"
  version: 2
  readOnly: false

But when I clicked on save and test I got some errors. I think I miss formated the provisioning file. I tried to upload the service account file using the UI and the test passed, I was able to query BQ. However when I did this, I couldn't find any file in /etc/grafana/provisioning/datasources to get and example of it.

I'm executing a custom grafana image in a docker container

### file system hierarchy of the project
.
├── Dockerfile
└── provisioning
    ├── dashborads
    └── datasources
        └── all.yaml
### Docker file 
ARG GRAFANA_VERSION=6.5.3
FROM grafana/grafana:$GRAFANA_VERSION
ENV GF_AUTH_DISABLE_LOGIN_FORM "true"
ENV GF_AUTH_ANONYMOUS_ENABLED "true"
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin"
ENV GF_INSTALL_PLUGINS "doitintl-bigquery-datasource 1.0.4"

The way I'm running the container

docker run -d -p 3000:3000 -v $(pwd)/provisioning:/etc/grafana/provisioning massy/custom-grafana

I'm providing the provisioning file via a volume.

How could I get the logs regarding the test of that bigquery plugin ?

avivl commented 4 years ago

@MassyB Sorry I'm familiar with the provisioning system. Regarding logs. The plugin is client-side, so all the logs can be found in the web browser log console

MassyB commented 4 years ago

@avivl thanks for the reply. I did a post on SO

MassyB commented 4 years ago

@avivl there is a difference between the two provisioning files:

The one on GitHub has the correct format I suggest you update the documentation in https://grafana.com/grafana/plugins/doitintl-bigquery-datasource?version=1.0.4 Thanks again for the plugin :-)

avivl commented 4 years ago

@MassyB Thank you. I'll do that next week