我有一个部署了kube-prometheus堆栈(prometheus、grafana、node-exporter)的helm图表,grafana配置中有一些json文件(仪表板),它们通过configMap传输到grafana pod(常见做法) )。我的任务是优化此配置,通过 grafana.com 的 id 添加 grafana 仪表板,而不是使用 json 文件(因为它们非常大)。我知道如何在grafana中创建文件夹并指定prometheus资源,但我不明白如何通过id导出仪表板。
为了创建一个文件夹,我有一个文件(yaml),该文件通过 configmap 添加到目录/etc/grafana/provisioning/dashboards
- name: 'default'
org_id: 1
folder: 'my-dashboards'
type: 'file'
options:
folder: '/var/lib/grafana/dashboards'
如何做到这一点以及我需要在哪个文件中插入此配置才能使其工作。我将不胜感激您的帮助。
我尝试创建在 github (dashboardProviders) 上找到的配置,但它只创建一个文件夹(我指定的代码),没有仪表板
UPD:我现在拥有的
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
但它仍然不起作用...为什么?
最佳答案
它是(或可以是)grafana helm chart 的一部分,据我记得过去使用时的情况。使用该 helm 图表时,该配置需要进入 values.yaml
。
具体here启用/配置 dashboardProviders
和 here使用 grafana 网站上的 dashboard id
来配置 dashboard
。
也可以引用一些文档here .
希望有帮助。
更新:
使用下面的配置,我能够导入 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
当然,我没有普罗米修斯数据源,因此有警告标志。
关于kubernetes - 如何通过 id 从 grafana.com 导入仪表板?没有 json 文件和 configMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75984109/