在构建容器时导入数据源和 grafana 仪表板



我正在尝试使用已经预配置的数据源和仪表板创建 docker 容器。 到目前为止,我可以理解从 v5.0 开始,grafana 引入了配置功能。 我创建了两个 yml 文件,首先是数据源,其次是仪表板。 但是我不明白docker-compose文件的哪一部分会调用这些datasource.yml和dashboarad.yml文件。我应该使用什么标签等等。以下是我的docker-compose,datasource和dashboard文件详细信息。 我能理解的撰写文件中的唯一细节是 -./grafana/provisioning/:/etc/grafana/provisioning/这是将一些主机文件夹结构复制到容器(但不确定(。

docker-compose.yml

grafana:
image: grafana/grafana
links:
- influxdb
ports:
- '3000:3000'
volumes:
- 'grafana:/var/lib/grafana'
- ./grafana/provisioning/:/etc/grafana/provisioning/

Dashboard.yml

apiVersion: 1
providers:
- name: 'Docker Dashboard'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 10 #how often Grafana will scan for changed dashboards
options:
path: <path-where-I-have-placed-jsonfile>

数据源.yml

datasources:
-  access: 'proxy'                       # make grafana perform the requests
editable: true                        # whether it should be editable
is_default: true                      # whether this should be the default DS
name: 'influx'                        # name of the datasource
org_id: 1                             # id of the organization to tie this datasource to
type: 'influxdb'                      # type of the data source
url: 'http://<ip-address>:8086'       # url of the prom instance
database: 'influx'
version: 1                            # well, versioning

volumes指令将仅在runtime而不是build运行,如果您希望它在build阶段工作,则需要使用COPY

Dockerfile:

FROM grafana/grafana
COPY ./grafana/provisioning /etc/grafana/provisioning

./grafana/provisioning应相对于Dockerfile

组成:

grafana:
build: .
.
.

最新更新