【问题标题】:Using BigQuery plugin in Grafana在 Grafana 中使用 BigQuery 插件
【发布时间】:2020-01-21 11:19:33
【问题描述】:

我对配置文件的格式有一些疑问。我有一些看起来像这样的服务帐户文件

{
  "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

【问题讨论】:

  • 您能否分享错误堆栈跟踪,以便我们更好地了解您面临的问题?
  • 在哪里可以找到这样的日志?插件在客户端
  • @Joaquim 我添加了一些日志
  • 你看过这篇文章了吗? community.grafana.com/t/…
  • 您能否在下面发布的答案中添加有关文档之间不同步的信息,以便社区可以从中受益?

标签: docker google-bigquery grafana


【解决方案1】:

这是配置文件的正确格式

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

这两个配置文件有区别:

GitHub上的格式正确

【讨论】:

  • 感谢您的帮助 :-)
猜你喜欢
  • 2022-12-11
  • 2017-07-19
  • 1970-01-01
  • 2018-07-08
  • 1970-01-01
  • 1970-01-01
  • 2020-06-21
  • 2021-08-15
  • 1970-01-01
相关资源
最近更新 更多