简单的grafana和docker撰写设置

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的外观。

version: "3"
services:
# My grafana service 
  grafana:
    build:
      context: ./grafana
    container_name: grafana
    ports:
      - 9000:3000
    volumes:
      - grafana-data:/var/lib/grafana
# Explicitly define the persistent volume for your data storage
volumes:
  grafana-data:
    external: true

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是仪表板和数据源的配置。 例如,他们看起来像

# config file version
apiVersion: 1


providers:
# <string> an unique provider name
- name: My Dashboard
  # <int> org id. will default to orgId 1 if not specified
  org_id: 1
  # <string, required> name of the dashboard folder. Required
  folder: ''
  # <string, required> provider type. Required
  type: 'file'
  # <bool> disable dashboard deletion
  disableDeletion: false
  # <bool> enable dashboard editing
  editable: true
  # <int> how often Grafana will scan for changed dashboards
  updateIntervalSeconds: 5
  # <bool> allow updating provisioned dashboards from the UI
  allowUiUpdates: true
  options:
    # <string, required> path to dashboard files on disk. Required
    path: /etc/grafana/dashboards
    # <bool> use folder names from filesystem to create folders in Grafana
    foldersFromFilesStructure: true

The next configuration file, grafana.ini:

下一个配置文件grafana.ini

[paths]
provisioning = /etc/grafana/provisioning


[server]
enable_gzip = true
# To add HTTPS support:	
#protocol = https	
#;http_addr =	
#http_port = 3000	
#domain = localhost	
#enforce_domain = false	
#root_url = https://localhost:3000	
#router_logging = false	
#static_root_path = public	
#cert_file = /etc/certs/cert.pem	
#cert_key = /etc/certs/cert-key.pem


[security]
# If you want to embed grafana into an iframe for example
allow_embedding = true


[users]
default_theme = dark

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/swlh/easy-grafana-and-docker-compose-setup-d0f6f9fcec13

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值