ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Create Grafana and InfluxDB Docker Containers in Ubuntu-14.04

InfluxDB : InfluxDB is an open-source time series database written in Go that has been built to work best with metrics, events, and analytics. Using InfluxDB, you can easily store system and application performance data and manage any time series data.

Grafana : Grafana is an open-source, general purpose dashboard that is used for visualizing time series data for Internet infrastructure and application analytics. Grafana supports graphite, influxdb or opentsdb as backends and runs as a web application.

In this tutorial, we will learn how to create and run Grafana and InfluxDB Docker containers in Ubuntu 14.04.

Requirements

  • A server running Ubuntu-14.04 with Docker installed.
  • A non-root user with sudo privileges setup on server.

Creating The Dockerfile

First, you will need to create the Docker file to install all requisite software. Create docker file inside your home directory using the following command:

sudo nano Dockerfile

Add the following lines with all requisite software:

    FROM ubuntu
    MAINTAINER Hitesh Jethva (hitjethva@gmail.com)

RUN apt-get update && apt-get -y --no-install-recommends install ca-certificates software-properties-common python-django-tagging python-simplejson python-memcache python-ldap python-cairo python-pysqlite2 python-support python-pip gunicorn supervisor nginx-light nodejs git curl openjdk-7-jre build-essential python-dev

Add the following lines to install Grafana, InfluxDB, and do some basic configuration:

    WORKDIR /opt
    RUN 
      curl -s -o /opt/grafana-1.8.1.tar.gz http://grafanarel.s3.amazonaws.com/grafana-1.8.1.tar.gz && 
      curl -s -o /opt/influxdb_latest_amd64.deb http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb && 
    mkdir /opt/grafana && 
      tar -xzvf grafana-1.8.1.tar.gz --directory /opt/grafana --strip-components=1 && 
      dpkg -i influxdb_latest_amd64.deb && 
      echo "influxdb soft nofile unlimited" >> /etc/security/limits.conf && 
      echo "influxdb hard nofile unlimited" >> /etc/security/limits.conf

Next, copy some configuration files:

    ADD config.js /opt/grafana/config.js
    ADD nginx.conf /etc/nginx/nginx.conf
    ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
    ADD types.db /opt/influxdb/current/types.db
    ADD config.toml /opt/influxdb/current/config.toml

Next, map volumes, expose ports, and setup the run command:

    VOLUME ["/opt/influxdb/shared/data"]

EXPOSE 80 8083 8086 8096

CMD ["supervisord", "-n"]

After adding all the content, your file should looks like the following:

    FROM ubuntu
    MAINTAINER Hitesh Jethva (hitjethva@gmail.com)

RUN apt-get update && apt-get -y --no-install-recommends install ca-certificates software-properties-common python-django-tagging python-simplejson python-memcache python-ldap python-cairo python-pysqlite2 python-support python-pip gunicorn supervisor nginx-light nodejs git curl openjdk-7-jre build-essential python-dev

WORKDIR /opt RUN curl -s -o /opt/grafana-1.8.1.tar.gz http://grafanarel.s3.amazonaws.com/grafana-1.8.1.tar.gz && curl -s -o /opt/influxdb_latest_amd64.deb http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb && mkdir /opt/grafana && tar -xzvf grafana-1.8.1.tar.gz --directory /opt/grafana --strip-components=1 && dpkg -i influxdb_latest_amd64.deb && echo "influxdb soft nofile unlimited" >> /etc/security/limits.conf && echo "influxdb hard nofile unlimited" >> /etc/security/limits.conf

ADD config.js /opt/grafana/config.js ADD nginx.conf /etc/nginx/nginx.conf ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf ADD types.db /opt/influxdb/current/types.db ADD config.toml /opt/influxdb/current/config.toml

VOLUME ["/opt/influxdb/shared/data"]

EXPOSE 80 8083 8086 8096

CMD ["supervisord", "-n"]

Configure Grafana

Once Dockerfile is created, you will need to create config.js file at your home directory:

sudo nano config.js

Add / Edit the following lines as per your requirements:

    datasources: {
        influxdb: {
          type: 'influxdb',
          url: "http://your-server-ip:8086/db/testdb",
          username: 'root',
          password: 'root',
        },
        grafana: {
          type: 'influxdb',
          url: "http://your-server-ip:8086/db/grafana",
          username: 'root',
          password: 'root',
          grafanaDB: true
        },
      },

Configure InfluxDB

Next, you will need to enable collectdb in InfluxDB's config.toml

sudo nano config.toml

Add / Edit the following lines:

    [input_plugins]
      [input_plugins.collectd]
      enabled = true
      port = 8096
      database = "testdb"
      typesdb = "/opt/influxdb/current/types.db"

Building the Container

Once you have finished, it's time to build container. Before starting, make sure you're working directory has your Dockerfile and configuration files in it.

Now, run the following command to create the container:

sudo docker build -t influx .

-t perameter specify the name of the image.

Once you have built the container, you will need to start the container. You can do this by running the following command:

sudo docker run --name influx -d -v /opt/influxdb/:/opt/influxdb/shared/data -p 80:80 -p 8083:8083 -p 8086:8086 -p 8096:8096/udp influx

The above command starts the influx image, map the container path of /opt/influxdb/shared/data to your local /opt/influxdb, your local port 80, 8083, and 8086 to the exposed ports in the container and map port 8096 to UDP.

You can check the container is running by issuing the following command:

sudo docker ps

Accessing Grafana and InfluxDB

Once everything is up-to-date, you can reach the grafana web interface by typing the URL http://your-server-ip in your web browser, you should see the Grafana default page as below:

You can the access InfluxDB management interface using the URL http://your-server-ip:8083 on your web browser.

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans