docker - 在 Grafana 中使用 BigQuery 插件
问题描述
我对配置文件的格式有一些问题。我有一些看起来像这样的服务帐户文件
{
"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"
}
我放入的配置文件/etc/grafana/provisioning/datasources/all.yaml
看起来像这样
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
但是当我点击保存并测试时,我得到了一些错误。我想我错过了配置文件的格式。我尝试使用 UI 上传服务帐户文件,测试通过,我能够查询 BQ。但是,当我这样做时,我找不到任何文件/etc/grafana/provisioning/datasources
来获取它的示例。
我正在 docker 容器中执行自定义 Grafana 映像
### 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"
我运行容器的方式
docker run -d -p 3000:3000 -v $(pwd)/provisioning:/etc/grafana/provisioning massy/custom-grafana
我通过卷提供配置文件。
配置文件有什么问题?当我们在 Grafana 中添加数据源时,配置文件不会自动更新吗?(如果没有创建,那么它将是?)当我测试那个 bigquery 插件时,我怎么能得到日志?
编辑
当我尝试在“新仪表板”部分添加一个虚拟 SQL 查询时,这就是我得到的
lvl=eror msg="Failed to get access token" logger=data-proxy-log error="private key should be a PEM or plain PKCS1 or PKCS8; parse error: asn1: structure error: tags don't match (16 vs {class:0 tag:28 length:110 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} pkcs1PrivateKey @2"
t=2020-01-22T10:02:18+0000 lvl=info msg=Requesting logger=data-proxy-log url=https://www.googleapis.com/bigquery/v2/projects/undefined/queries
t=2020-01-22T10:02:18+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=1 uname= method=POST path=/api/datasources/proxy/1/bigquery/v2/projects/undefined/queries status=401 remote_addr=172.17.0.1 time_ms=55 size=304 referer="http://localhost:3000/dashboard/new?panelId=2&edit&fullscreen&orgId=1&gettingstarted"
我docker logs
在容器上做了一个
解决方案
这是配置文件的正确格式
apiVersion: 1
datasources:
- 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-----
XXXXXXX_my_private_key___
XXXXX_another_line_here_XXXXX
XXXXXX_final_line_XXXXXX
-----END PRIVATE KEY-----
version: 2
readOnly: false
两个配置文件之间存在差异:
- https://grafana.com/grafana/plugins/doitintl-bigquery-datasource?version=1.0.4
- https://github.com/doitintl/bigquery-grafana#example-of-provisioning-a-file
GitHub上的那个格式正确
推荐阅读
- python - AzureML:当新版本的模型可用时自动更新部署
- mysql - MySQL 错误:列“位置”不能为空
- javascript - 获取未知深度JavaScript对象内的元素
- python - 如何在 Python 中下载网页的音频内容?
- android - Android自动备份不起作用:传输被拒绝的包,因为它当时无法处理它
- python - discord.py on_message_delete 获取消息内容
- php - 从字符串列表中查找带有字符和字符+数字组合的字符串
- wso2 - WSO2 从文本文件的开头删除空格
- html - 是否有另一种不使用引导程序来获取图标的方法
- sql - 为什么在创建 sql 临时表时出现错误?