Over a million developers have joined DZone.

Using Gnocchi With Docker

DZone 's Guide to

Using Gnocchi With Docker

A new open source project brings Gnocchi and Docker together to allow for easy distribution of Gnocchi, which can be used with other tools for data visualization.

· Cloud Zone ·
Free Resource

I've recently started to look into Docker to build images ready to be used with Gnocchi. I found it would be a great way to distribute a working instance of Gnocchi.

To this end, we created the gnocchi-docker repository on GitHub. It contains:

  • An 11-lines-long Dockerfile to build a Linux image containing Gnocchi.
  • Dockerfile to create a Grafana image that will use Gnocchi as a datasource (pre-configured).
  • Dockerfile to create a collectd image that gathers various metrics for your container in order to feed Gnocchi and have something to display in Grafana.
  • docker-compose file that orchestrates and runs those containers.

If you don't know docker-compose, it's a tool to define and run applications using multiple containers. This is very handy in our case, as we need to start a few services, and therefore a few containers, to have our whole stack running.

If you just want to use and run Gnocchi in a snap using this, it's easy. First, clone the repository:

$ git clone https://github.com/gnocchixyz/gnocchi-docker.git

 Then, just ask docker-compose to start your stack of containers:

$ cd gnocchi-docker
$ docker-compose up

On the first run, docker-compose will build the various images (this should take only a few minutes) and then start them.

Once everything is started, you can connect to Grafana by typing the URL http://<ip of your docker server>:3000 into your browser and using "admin" as the username and "password" as the password. Just click on the dashboard titled "Gnocchi" and wait a few minutes. You will see the chart being drawn in real time!

Grafana dashboard with Gnocchi as backend

The data fed into Gnocchi comes from the collectd container, which gathers various metrics (CPU, network interface statistics, etc).

You can then edit the Dockerfiles as you like to add new features or test your code. The files are also a good basis if you want to deploy Gnocchi in production running Docker!

If you want to access and play with Gnocchi in the command line, just install gnocchiclient and do the following:

$ export GNOCCHI_ENDPOINT=http://`docker-machine ip`:8041
$ gnocchi resource list
| id       | type     | project_id | user_id | original_resource_id | started_at | ended_at | revision_start | revision_end | creator |
| c31e4adc | collectd | None       | None    | collectd:fake-phy-   | 2017-08-17 | None     | 2017-08-17T12: | None         | admin   |
| -2cff-5f |          |            |         | host-719acbad336c    | T12:20:27. |          | 20:27.643790+0 |              |         |
| 78-8206- |          |            |         |                      | 643778+00: |          | 0:00           |              |         |
| f5ca66e4 |          |            |         |                      | 00         |          |                |              |         |
| 6cce     |          |            |         |                      |            |          |                |              |         |

You can now have fun creating new resources and metrics!

Feel free to contribute patches to the GitHub project too, obviously!

cloud ,gnocchi ,docker ,containerization ,data visualization ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}