Monitoring Your System with Graphite and a Grafana Dashboard

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

What are Graphite and Grafana?

Graphite is an open-source monitoring tool for storing and viewing time series data. It does not collect data, but has a simple interface and integrates easily with third-party tools. Grafana allows you to connect to a Graphite installation (or other data source) and build dashboards to view and analyze the data.

This guide uses Docker Compose to run the official Grafana and Graphite containers and connect them to a user-defined network. This makes it easy to securely connect a Grafana dashboard to the Graphite database.

Why use Grafana over Graphite’s visualization?

Graphite has a built-in Composer for the user to view metrics visually and also offers a rich render API. That being said, Graphite’s built-in visualization is rudimentary, and the developers suggest Grafana for a “more modern UI,” that is “another great way to interact with Graphite data and it offers many more visualization types than the native Composer” (see the bottom of the page at https://graphiteapp.org/quick-start-guides/graphing-metrics.html).

Installing Graphite and Grafana

Both Docker and Docker Compose are necessary to complete this guide.

Install Docker

To install Docker CE (Community Edition), follow the instructions within one of the guides below:

To see installation instructions for other Linux distributions or operating systems like Mac or Windows, reference Docker’s official documentation here: Install Docker Engine

Install Docker Compose

Docker Compose is available in plugin and standalone variants. However, Docker’s official documentation prioritizes the plugin. Further, the plugin has a straightforward installation and works well with past Docker Compose commands.

These steps thus show how to install the Docker Compose plugin. If you are interested in installing the standalone Docker Compose application, follow Docker’s official installation guide.

Note

Many tutorials retain the Docker Compose standalone command format, which looks like the following:

docker-compose [command]

Be sure to replace this with the plugin’s command format when using this installation method. This typically just means replacing the hyphen with a space, as in:

docker compose [command]
  1. Enable the Docker repository for your system’s package manager. The repository is typically already enabled after you have installed the Docker engine. Follow our relevant guide on installing Docker to enable the repository on your system.

  2. Update your package manager, and install the Docker Compose plugin.

    • On Debian and Ubuntu systems, use the following commands:
    sudo apt update
    sudo apt install docker-compose-plugin
    • On CentOS, Fedora, and other RPM-based distributions, use the following commands:
    sudo yum update
    sudo yum install docker-compose-plugin

Docker Compose Configuration for Graphite and Grafana

  1. Create a directory:

    mkdir ~/grafana && cd ~/grafana
    
  2. In a text editor, create docker-compose.yml and add the following content:

    File: docker-compose.yml
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    
    version: "3"
    services:
      grafana:
        image: grafana/grafana
        container_name: grafana
        restart: always
        ports:
          - 3000:3000
        networks:
          - grafana-net
        volumes:
          - grafana-volume
    
      graphite:
        image: graphiteapp/graphite-statsd
        container_name: graphite
        restart: always
        networks:
          - grafana-net
    
    networks:
      grafana-net:
    
    volumes:
      grafana-volume:
        external: true

    This Compose file uses the official Docker images for both Graphite and Grafana. It also specifies a network to connect the containers.

  3. Since the data volume is external, create it manually:

    docker volume create --name=grafana-volume
    
  4. Bring up the configuration:

    docker-compose up -d
    
  5. Check that both containers started successfully:

    docker ps
    
    CONTAINER ID        IMAGE                         COMMAND             CREATED             STATUS              PORTS                                                                     NAMES
    494e45f7ab56        grafana/grafana               "/run.sh"           19 seconds ago      Up 7 seconds        0.0.0.0:3000->3000/tcp                                                    grafana
    49881363d811        graphiteapp/graphite-statsd   "/sbin/my_init"     19 seconds ago      Up 7 seconds        80/tcp, 2003-2004/tcp, 2023-2024/tcp, 8080/tcp, 8125-8126/tcp, 8125/udp   graphite

Add a Data Source for Graphite and Create a Grafana Dashboard

  1. In a browser, navigate to port 3000 on the Linode’s FQDN or public IP address (192.0.2.0:3000). The Grafana login page loads:

  2. Log in using the default admin account (username and password are both admin).

  3. Click Create data source in the main dashboard and fill in the form as follows:

    Grafana Add Data Source

    • Name: Graphite
    • Type: Graphite
    • URL: http://graphite:8080
    • Access: Server (Default)
    • Version: Select the newest available. 1.1.3 in this example.

    Click Save & Test.

  4. Click New dashboard to create and customize a new panel:

    • To import a sample Dashboard, try the Internal Grafana Stats.

      1. Click New dashboard at the top, then Import dashboard.
      2. Type 55 into the Grafana.com Dashboard box, and click Load.
      3. Select Graphite in the data source dropdown, and click Import.
  5. Click the floppy disk icon or press CTRL+S to save.

  6. Click Add users to access the user management configuration tab.

  7. Hover over the user icon in the lower-left corner of the sidebar and click Preferences to open a menu where you can replace the default admin username and password with something more secure:

    Admin Preferences

Next Steps

Graphite does not collect data by itself. See the Graphite documentation for a list of third-party tools to add data for visualization. A larger, distributed deployment of Graphite may not be suitable for the containerized approach taken in this guide. If this is your use case, see their documentation on installing Graphite from scratch.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.