【问题标题】:Importing datasource and grafana dashboard while building container在构建容器时导入数据源和 grafana 仪表板
【发布时间】:2019-09-30 10:35:42
【问题描述】:

我正在尝试使用已预配置的数据源和仪表板创建 docker 容器。 到目前为止,我可以理解,从 v5.0 开始,grafana 已经引入了配置功能。 我创建了两个 yml 文件,首先是数据源,其次是仪表板。 但我不明白 docker-compose 文件的哪一部分会调用这些 datasource.yml 和 dashboarad.yml 文件。我应该使用什么标签等等。下面是我的 docker-compose、数据源和仪表板文件详细信息。 我可以理解的撰写文件中唯一的细节是 - ./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/

仪表板.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

【问题讨论】:

    标签: docker docker-compose grafana influxdb


    【解决方案1】:

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

    Dockerfile:

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

    ./grafana/provisioning 应该相对于Dockerfile

    撰写:

    grafana:
        build: .
        .
        .
    

    【讨论】:

    • 我应该复制 datasource.yml /etc/grafana/provisioning 吗?和仪表板一样?
    • 我有一个 docker 文件,用于构建 influxdb 映像以及 grafana FROM influxdb COPY init.iql /docker-entrypoint-initdb.d/ FROM grafana/grafana COPY datasource.yml / etc/grafana/provisioning 复制dashboard.yml /etc/grafana/provisioning.会不会出问题?
    • 您不能同时使用单个 dockerfile,这将创建多级 docker 文件,我认为您不想这样做。我认为您需要创建两个 dockerfile 并使用 compose 管理它们
    • 我创建了两个名为 grafana 和 influxdb 的文件夹,并将 dockerfile 放在其中。在 dockercompose 文件中,我有服务:influxdb: build: 。和服务:grafana:构建:. (文件夹名称是grafana和influxdb?我猜这是正确的方式)
    • 是的,在撰写中使用context: .dockerfile: grafana/Dockerfilebuilddirective下
    猜你喜欢
    • 1970-01-01
    • 2018-11-23
    • 2019-07-13
    • 2019-11-14
    • 2019-07-25
    • 2020-09-18
    • 1970-01-01
    • 2019-06-25
    • 1970-01-01
    相关资源
    最近更新 更多