从grafana.com按ID导入仪表板,无需JSON文件和configMap。

huangapple go评论56阅读模式
英文:

How do I import dashboards by id from grafana.com? Without json files and configMap

问题

I understand that you want assistance with a Kubernetes Helm chart for deploying a kube-prometheus stack and configuring Grafana dashboards using their IDs from grafana.com. To do this, you need to make changes to the Grafana configuration.

You should insert the configuration you provided into a YAML file, typically named something like grafana-dashboard-providers.yaml, and then include this file as a ConfigMap in your Kubernetes deployment.

This configuration sets up a Grafana provider named 'prometheus' and specifies a dashboard folder named 'my-dashboards.' To add Grafana dashboards via their IDs, you would typically specify them under the 'dashboards' section within the same file, like you did for the 'MinIO' dashboard. However, make sure that the dashboard IDs you specify are correct.

After making these changes and applying the ConfigMap to your Kubernetes cluster, Grafana should recognize the dashboards by their IDs and display them. If it's still not working, double-check the dashboard IDs and Grafana configuration for any potential issues.

英文:

I have a helm chart that deploys a kube-prometheus stack (prometheus, grafana, node-exporter), there are some json files (dashboards) in the grafana configuration, they are transferred to the grafana pod via configMap (common practice). I have a task to optimize this configuration to add grafana dashboards via their id from grafana.com and not to use json files (as they are very big). I know how to create a folder in grafana and specify the prometheus resource, but I don't understand how to export dashboards by id.

To create a folder I have a file (yaml) which is added via configmap to the directory /etc/grafana/provisioning/dashboards

- name: 'default'
  org_id: 1
  folder: 'my-dashboards'
  type: 'file'
  options:
    folder: '/var/lib/grafana/dashboards'

How to do it and in which file I need to insert this configuration to make it work. I will be grateful for help.

I tried to create configurations I found on github (dashboardProviders), but it only creates a folder (the code I specified), without dashboards

UPD: what i have now

apiVersion: 1
providers:
  # <string> an unique provider name. Required
  - name: 'prometheus'
    # <int> Org id. Default to 1
    orgId: 1
    # <string> name of the dashboard folder.
    folder: 'my-dashboards'
    # <string> folder UID. will be automatically generated if not specified
    folderUid: ''
    # <string> provider type. Default to 'file'
    type: file
    # <bool> disable dashboard deletion
    disableDeletion: false
    # <int> how often Grafana will scan for changed dashboards
    updateIntervalSeconds: 10
    # <bool> allow updating provisioned dashboards from the UI
    allowUiUpdates: false
    options:
      # <string, required> path to dashboard files on disk. Required when using the 'file' type
      path: /var/lib/grafana/dashboards
      # <bool> use folder names from filesystem to create folders in Grafana
      foldersFromFilesStructure: true

dashboards:
  default:
    MinIO:
      gnetId: 13502
      revision: 2
      datasource: prometheus

but it still doesn't work...why?

答案1

得分: 2

以下是已翻译的内容:

这是grafana helm chart的一部分(或可以是一部分),根据我过去的使用经验。当使用该helm chart时,该配置需要放入values.yaml中。

具体地,在这里可以启用/配置dashboardProviders,而在这里可以使用grafana网站上的dashboard id来创建dashboard

还可以参考一些文档这里

希望有所帮助。

更新:

使用以下配置,我能够导入MinIO仪表板(与OP尝试导入的相同):

dashboardProviders:
  dashboardproviders.yaml:
    apiVersion: 1
    providers:
    - name: 'default'
      orgId: 1
      folder: 'default'
      type: file
      disableDeletion: true
      editable: true
      options:
        path: /var/lib/grafana/dashboards/standard

dashboards:
  default:
    MinIO:
      gnetId: 13502
      revision: 2
      datasource: prometheus

当然,我没有prometheus数据源,因此会显示警告标志。

英文:

It is (or can be) a part of the grafana helm chart, from what I remember when used it in the past. That configuration needs to go into the values.yaml when using that helm chart.

Specifically here to enable/configure dashboardProviders and here to provision the dashboard using dashboard id from the grafana website.

Can also refer to some documentation here.

Hope it helps.

Update:

Using the below config I was able to import the MinIO Dashboard (the one OP tried to import):

dashboardProviders:
  dashboardproviders.yaml:
   apiVersion: 1
   providers:
   - name: 'default'
     orgId: 1
     folder: 'default'
     type: file
     disableDeletion: true
     editable: true
     options:
       path: /var/lib/grafana/dashboards/standard

dashboards:
  default:
    MinIO:
      gnetId: 13502
      revision: 2
      datasource: prometheus

从grafana.com按ID导入仪表板,无需JSON文件和configMap。

Ofcourse I don't have the prometheus data source, hence the warning sign(s).

huangapple
  • 本文由 发表于 2023年4月11日 17:00:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75984109.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定