K6 InfluxDB + Grafana Docker : How to preload a dashboard

送分小仙女□ 提交于 2020-12-14 09:32:42

问题


I am using K6 for Load Testing.

I have cloned the K6, Grafana, InfluxDB docker-compose set up from here:

https://github.com/loadimpact/k6

Each time I start Grafana, I have to manually import the dashboard I want to use ('Import' - ID2587 - Load).

I am new to Docker (and Grafana!)....is there anyway to have this dashboard preloaded in the container so I don't have to manually add it each time?


回答1:


mount your dashboard and datasources into grafana container when running docker-compose up -d influxdb grafana refer the docker-compose file and grafana folder here

And make sure the datasource in your dashboard.json is updated with name of the datasource mentioned in datasource.yml

I have created a small tutorial in k6 community. Hope this solves your case.




回答2:


A few small improvements which I think can help the docker-compose setup be awesome to use:

  1. Use the awesome 'k6 Load Testing Results - by dcadwallader' dashboard: https://grafana.com/grafana/dashboards/2587

  2. Map a local dashboards directory, as well as the settings for the dashboard with all of the org ids and settings pre-configured, e.g.:

     volumes:
       - ./dashboards:/var/lib/grafana/dashboards
       - ./grafana-dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
       - ./grafana-datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
    

    https://github.com/luketn/docker-k6-grafana-influxdb/blob/master/docker-compose.yml#L32-L35

  3. Set the uid in the dashboard JSON file for consistent links, e.g.:

    {
      uid: "k6",
    

    https://github.com/luketn/docker-k6-grafana-influxdb/blob/master/dashboards/k6-load-testing-results_rev3.json#L53

Ref: https://medium.com/swlh/beautiful-load-testing-with-k6-and-docker-compose-4454edb3a2e3

And: https://github.com/luketn/docker-k6-grafana-influxdb



来源:https://stackoverflow.com/questions/63501972/k6-influxdb-grafana-docker-how-to-preload-a-dashboard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!