docker - 在 Grafana 中使用 BigQuery 插件

标签 docker google-bigquery grafana

我对配置文件的格式有一些问题。我有一些类似这样的服务帐户文件

{
  "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": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0c6175217c7e6366696f784c6f63617c6d627522656d61226b7f697e7a656f696d6f6f63796278226f6361" rel="noreferrer noopener nofollow">[email protected]</a>",
  "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: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4c9dd89d4d6cbcec1c7d0e4c7cbc9d4c5cadd8acdc5c98ac3d7c1d6d2cdc7c1c5c7c7cbd1cad08ac7cbc9" rel="noreferrer noopener nofollow">[email protected]</a>
  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日志

最佳答案

这是配置文件的正确格式

apiVersion: 1

datasources:
- name: bigquery-project
  type: doitintl-bigquery-datasource
  access: proxy
  isDefault: true
  jsonData:
     authenticationType: jwt
     clientEmail: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="80edf9adf0f2efeae5e3f4c0e3efedf0e1eef9aee9e1edaee7f3e5f2f6e9e3e5e1e3e3eff5eef4aee3efed" rel="noreferrer noopener nofollow">[email protected]</a>
     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

两个配置文件之间存在差异:

GitHub 上的格式正确

关于docker - 在 Grafana 中使用 BigQuery 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59840012/

相关文章:

Grafana Worldmap-Panel 阈值选项不起作用

influxdb - 引用 Grafana 中的现有面板

graph - 我想在 Grafana 中的图表上设置警报,但我无法设置

google-bigquery - 有没有办法在 Bigquery 表通配符查询中选择 table_id

python - 可以在不填充数据的情况下创建 BigQuery 表/模式吗?

datetime - 如何在 BigQuery SQL 中捕获失败的 CAST 语句?

docker - 命令在heroku命令行上有效,但在推送的docker镜像中无效

docker - Spinnaker 构建不会在重新推送现有标签(如最新)时触发

reactjs - 设置Nginx代理以进行React应用

reactjs - Nginx 反向代理和多个 React 应用程序