My team has been working on solutions in order to quickly maintain, scale, and visualize internal software suites used for work in modeling and simulation, networking, and more. Before stumbling on Grafana, an incredible open source project for dashboard generation, we were coding our own custom plots in Javascript. The customization was nice, but it took a lot of time and it forced us to edit the source code often. From never knowing how to use Grafana it took no time to setup and we basically had all the same plots as before!
我的团队一直在研究解决方案,以便快速维护,缩放和可视化用于建模和仿真,联网等工作的内部软件套件。 在迷上Grafana (一个令人难以置信的用于仪表板生成的开源项目)之前,我们已经用Javascript编写了自己的自定义图。 定制很好,但是花了很多时间,这迫使我们经常编辑源代码。 由于从不知道如何使用Grafana,因此无需花费任何时间进行设置,而我们基本上拥有与以前相同的地块!
Now, we are able to launch an entire visualization suite alongside our Docker development environment. I wont get into the specifics of the environment, but our teams have generally switched to running all software development kits with docker and docker-compose. We are able to launch the SDK, a database, and the grafana visualization in one go. This allows for a seamless start-up for our developers and awesome looking plots. All you need is docker and docker-compose installed!
现在,我们能够与Docker开发环境一起启动整个可视化套件。 我不会深入介绍环境的细节,但是我们的团队通常已切换到使用docker和docker-compose运行所有软件开发工具包。 我们能够一口气启动SDK,数据库和grafana可视化。 这为我们的开发人员和精美的地块提供了一个无缝的启动环境。 您只需要安装docker和docker-compose即可!
This quick article will show a grafana user to provision, version control, and add grafana to a docker-compose setup so a user can launch a powerful development and analysis tool in a single go.
这篇简短的文章将向您展示grafana用户的调配,版本控制,并将grafana添加到docker-compose设置中,以便用户一次即可启动功能强大的开发和分析工具。
Here is a look at the compose file and the associated Dockerfile.
这是组成文件和关联的Dockerfile的外观。
Note, you could just launch the compose with image: grafana/grafana
instead of using build:
but this allows for more customization, easier user installation, and versioning.
请注意,您可以使用image: grafana/grafana
来启动compose而不是使用build:
但这允许更多的自定义,更容易的用户安装和版本控制。
If you wish anything to persist when you make changes to your dashboard or configurations, you must add a named volume to the setup. To create this volume,
如果希望在更改仪表板或配置时保留任何内容,则必须在设置中添加一个命名卷。 要创建此卷,
$ docker volume create grafana-data
I am assuming a user already has or knows how to create a json model for the dashboard and add a data source. If you do not, you can sill follow the setup and create your own dashboard later!
我假设用户已经拥有或知道如何为仪表板创建json模型并添加数据源 。 如果您不这样做,则可以按照设置进行操作,稍后再创建自己的仪表板!
There are three things we add to the docker image: provisioning, grafana.ini, and dashboards. All of which are easily versioned controlled and can be released to update all your developers environments.
我们在Docker映像中添加了三件事:供应,grafana.ini和仪表板。 所有这些都易于版本控制,可以发布以更新所有开发人员环境。
The provisioning is added so a user does not have to do any configuration to setup datasources or dashboards and are instead created automatically when launched. Here is what the structure looks like:
在供应增加,因此用户不必做设置数据源或仪表板的任何配置和启动时,而不是自动创建的。 结构如下所示:
|-- provisioning
|-- dashboards
| `-- dashboard.yml
`-- datasources
`-- datasource.yml
The .yml
are configurations for dashboards and datasources. For example they can look like,
.yml
是仪表板和数据源的配置。 例如,他们看起来像
The next configuration file, grafana.ini
:
下一个配置文件grafana.ini
:
It is used to set multiple grafana configurations for ease of use. There are tons of possible options here that will meet most users requirements.
它用于设置多个grafana 配置以便于使用。 这里有大量可能的选项可以满足大多数用户的需求。
The dashboards directory contains your json model(s) for your dashboard(s).
仪表板目录包含您的仪表板的json模型。
|-- dashboards
| `-- my-dashboard.json
And that is it. This was a brief look at a quick way to integrate grafana into your workflow. With these created you can easily version control the entire setup and push it out to users. Launch the setup with,
就是这样。 简要介绍了将grafana集成到您的工作流程中的快速方法。 创建这些文件后,您可以轻松地控制整个设置的版本,并将其推出给用户。 使用以下命令启动设置
$ docker-compose up
The docker image will be built for you and the service will launch the grafana homepage at http://localhost:9000.
将会为您构建docker映像,该服务将在http:// localhost:9000启动grafana主页。
As you continue and want to make this a more versatile setup you could add a database service and your own docker development environment. This would allow you to launch a powerful dev environment with a single command all connected via its own docker network.
当您继续并希望使它成为更通用的设置时,您可以添加数据库服务和您自己的docker开发环境。 这样一来,您就可以通过单个命令来启动功能强大的开发环境,这些命令均通过其自己的docker网络连接。
翻译自: https://medium.com/@gbryan93/easy-grafana-and-docker-compose-setup-d0f6f9fcec13