Getting ready

Graphite is an application that is written in Python and is, thus, capable of running on virtually any system supporting Python and its libraries. There are multiple ways of installing Graphite on any given system, ranging from compilation from a source, using pip all the way, to prebuilt RPMs for various Linux distributions.

For all the different installation strategies, take a look at the Graphite documentation at http://graphite.readthedocs.org/en/latest/install.html. OS X users can read a very good step-by-step guide located at https://gist.github.com/relaxdiego/7539911.

For the purposes of this recipe, we will use a premade Docker container containing Graphite as well as its counterpart Grafana. While there is an abundance of various prebuilt variants of Docker images containing combinations of Graphite and Grafana, we will use the one from https://registry.hub.docker.com/u/alexmercer/graphite-grafana/ as it contains all the right configurations that will make it easy for us to get started quickly:

  1. The first step will be to download the desired Docker container image. We will do this by executing docker pull alexmercer/graphite-grafana. The container size is about 500 MB; so the download might take a few minutes depending on your connection speed.
  2. Both Graphite and Grafana store their data in the database files. We will need to create external directories, which will reside outside the container, and we will connect them to a running instance via Docker data volumes.
    • Make a directory for the Graphite data anywhere in your system, for example, in <user_home>/data/graphite.
    •  Make a directory for the Grafana data, for example, in <user_home>/data/grafana.
  3. In this container, the Graphite data will go to /var/lib/graphite/storage/whisper, while Grafana stores its data in /usr/share/grafana/data. So, we will use these paths as internal volume mount destinations when starting the container.
  4. Run the container by executing docker run -v <user_home>/data/graphite:/var/lib/graphite/storage/whisper -v <user_home>/data/grafana:/usr/share/grafana/data -p 2003:2003 -p 3000:3000 -p 8888:80 -d alexmercer/graphite-grafana.
    • In Docker, the -v option configures a volume mount binding. In our example, we configured the external <user_home>/data/graphite directory to be the same as the /var/lib/graphite/storage/whisper directory reference in the container. The same goes for the <user_home>/data/grafana mapping. We can even look in the <user_home>/data/graphite or data/grafana directories to see them contain the subdirectories and files.
    • The -p option configures the port mappings similar to the directory volumes. In our example, we mapped the following three different ports to be accessible from outside the container to the internal ports to which the various services are bound:
      2003:2003: This port mapping externalizes the Graphite data stream listener known as Carbon-Cache Line Receiver, to which we will connect in order to send the metrics data.
      3000:3000: This port mapping externalizes the Grafana Web Dashboard UI, which we will use to create visual dashboards on top of the Graphite data.
      8888:80: This port mapping externalizes the Graphite Web UI. Though it is running on port 80 in the container, it is unlikely that on our development machine, port 80 is open; so it is better to map it to some other higher number port such as 8080 or 8888 in our case, as 8080 is already taken by our BookPub application.
  1. If everything has gone according to the plan, Graphite and Grafana should be up and running and thus, we can access Graphite by pointing our browser to http://localhost:8888 and we should see the following output:
  1. To see Grafana, point the browser to http://localhost:3000 so as to see the following output:
  1. The default login and password for Grafana are admin/admin and can be changed via the Web UI Admin.
For the OS X users who use boot2docker, the IP would not be of the localhost, but rather a result of the boot2docker IP call.
  1. Once we are in Grafana, we will need to add our Graphite instance as DataSource, so click on the icon, go to Data Sources, and add a new source of the Type Graphite, Url http://localhost:80, Access  proxy:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.156.140