Skip to content

Commit

Permalink
Version 2.0 almost ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuele Bistoletti committed Jan 28, 2017
1 parent 2857db8 commit ab9151a
Show file tree
Hide file tree
Showing 20 changed files with 2,943 additions and 664 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Docker StatsD InfluxDB Grafana image
-----------------------------------

## v2.0.0 (2017-01-28)

* Ubuntu 16.04 LTS is the new Docker base image
* New init system with Supervisord
* StatsD InfluxDB backend connector removed
* StatsD Etsy removed
* StatsD has been fully replaced with InfluxData Telegraf, that supports StatsD protocol
* Upgraded InfluxDB to version 1.2
* Upgraded Grafana to version 4.1.1

## v1.0.2 (2016-09-15)

* Fix for bad proxy hash sum mismatch
Expand All @@ -14,4 +24,4 @@ Docker StatsD InfluxDB Grafana image

## v1.0.0 (2015-07-19)

* Initial release
* Initial release
119 changes: 57 additions & 62 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,105 +1,100 @@
FROM phusion/baseimage:0.9.18
FROM ubuntu:16.04
MAINTAINER Samuele Bistoletti <samuele.bistoletti@gmail.com>

CMD ["/sbin/my_init"]
ENV DEBIAN_FRONTEND noninteractive
ENV LANG C.UTF-8

# Default versions
ENV STATSD_VERSION 0.8.0
ENV INFLUXDB_VERSION 0.13.0
ENV GRAFANA_VERSION 3.0.4-1464167696
ENV TELEGRAF_VERSION 1.2.0
ENV INFLUXDB_VERSION 1.2.0
ENV GRAFANA_VERSION 4.1.1-1484211277

# Database Defaults
ENV INFLUXDB_GRAFANA_DB datasource
ENV INFLUXDB_GRAFANA_USER datasource
ENV INFLUXDB_GRAFANA_PW datasource

ENV MYSQL_GRAFANA_USER grafana
ENV MYSQL_GRAFANA_PW grafana

# Environment variables
ENV DEBIAN_FRONTEND noninteractive

# Fix bad proxy issue
ADD system/99fixbadproxy /etc/apt/apt.conf.d/99fixbadproxy
COPY system/99fixbadproxy /etc/apt/apt.conf.d/99fixbadproxy

# Clear previous sources
RUN rm /var/lib/apt/lists/* -vf

# Update system repositories
RUN apt-get -y update

# Upgrade system
RUN apt-get -y dist-upgrade

# Base dependencies
RUN apt-get -y --force-yes install\
curl\
wget\
git\
htop\
libfontconfig\
mysql-client\
mysql-server\
net-tools

# Create support directories
RUN mkdir -p /etc/my_init.d

# Set root password and configure SSH
RUN echo 'root:root' | chpasswd

RUN rm -f /etc/service/sshd/down
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN apt-get -y update && \
apt-get -y dist-upgrade && \
apt-get -y --force-yes install \
apt-utils \
ca-certificates \
curl \
git \
htop \
libfontconfig \
mysql-client \
mysql-server \
nano \
net-tools \
openssh-server \
supervisor \
wget && \
curl -sL https://deb.nodesource.com/setup_7.x | bash - && \
apt-get install -y nodejs

# Configure Supervisord, SSH and base env
COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

WORKDIR /root

RUN mkdir -p /var/log/supervisor && \
mkdir -p /var/run/sshd && \
sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
echo 'root:root' | chpasswd && \
rm -rf .ssh && \
rm -rf .profile && \
mkdir .ssh

COPY ssh/id_rsa .ssh/id_rsa
COPY bash/profile .profile

# Configure MySql
ADD mysql/run.sh /etc/my_init.d/01_run_mysql.sh
ADD scripts/setup_mysql.sh /tmp/setup_mysql.sh
RUN /tmp/setup_mysql.sh
COPY scripts/setup_mysql.sh /tmp/setup_mysql.sh

# Add Nodejs repository and install it
ADD scripts/setup_nodejs.sh /tmp/setup_nodejs.sh
RUN /tmp/setup_nodejs.sh
RUN apt-get -y --force-yes install nodejs
RUN /tmp/setup_mysql.sh

# Install InfluxDB
RUN wget https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VERSION}_amd64.deb && \
dpkg -i influxdb_${INFLUXDB_VERSION}_amd64.deb && rm influxdb_${INFLUXDB_VERSION}_amd64.deb

# Configure InfluxDB
ADD influxdb/influxdb.conf /etc/influxdb/influxdb.conf
ADD influxdb/run.sh /etc/my_init.d/02_run_influxdb.sh
ADD influxdb/init.sh /etc/init.d/influxdb
ADD scripts/setup_influxdb.sh /tmp/setup_influxdb.sh
RUN /tmp/setup_influxdb.sh

# Install StatsD
RUN git clone -b v${STATSD_VERSION} https://github.com/etsy/statsd.git /opt/statsd
COPY influxdb/influxdb.conf /etc/influxdb/influxdb.conf
COPY influxdb/init.sh /etc/init.d/influxdb

# Configure StatsD
ADD statsd/config.js /opt/statsd/config.js
ADD statsd/run.sh /etc/my_init.d/03_run_statsd.sh
# Install Telegraf
RUN wget https://dl.influxdata.com/telegraf/releases/telegraf_${TELEGRAF_VERSION}_amd64.deb && \
dpkg -i telegraf_${TELEGRAF_VERSION}_amd64.deb && rm telegraf_${TELEGRAF_VERSION}_amd64.deb

# Install StatsD InfluxDb Backend
RUN cd /opt/statsd && npm install git+https://github.com/gillesdemey/statsd-influxdb-backend.git
# Configure Telegraf
COPY telegraf/telegraf.conf /etc/telegraf/telegraf.conf
COPY telegraf/init.sh /etc/init.d/telegraf

# Install Grafana
RUN wget https://grafanarel.s3.amazonaws.com/builds/grafana_${GRAFANA_VERSION}_amd64.deb && \
dpkg -i grafana_${GRAFANA_VERSION}_amd64.deb && rm grafana_${GRAFANA_VERSION}_amd64.deb

# Configure Grafana
ADD grafana/grafana.ini /etc/grafana/grafana.ini
ADD grafana/run.sh /etc/my_init.d/04_run_grafana.sh

# Copy .bashrc
ADD system/bashrc /root/.bashrc
COPY grafana/grafana.ini /etc/grafana/grafana.ini

# Cleanup
RUN apt-get clean\
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Create volumes
VOLUME /var/log
VOLUME /var/lib/mysql
VOLUME /var/lib/influxdb
VOLUME /opt/statsd
VOLUME /root

CMD ["/usr/bin/supervisord"]
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Docker Image with StatsD, InfluxDB and Grafana
# Docker Image with Telegraf (StatsD), InfluxDB and Grafana

:facepunch: Battle-tested

[![CircleCI](https://circleci.com/gh/samuelebistoletti/docker-statsd-influxdb-grafana.svg?style=svg)](https://circleci.com/gh/samuelebistoletti/docker-statsd-influxdb-grafana)

## Versions

* StatsD: 0.8.0
* InfluxDB: 0.13
* Grafana: 3.0.4
* Ubuntu: 16.04
* InfluxDB: 1.2
* Telegraf (StatsD): 1.2
* Grafana: 4.1.1

## Quick Start

Expand All @@ -17,7 +18,7 @@ To start the container the first time launch:
```sh
docker run -d \
--name docker-statsd-influxdb-grafana \
-p 3003:9000 \
-p 3003:3003 \
-p 3004:8083 \
-p 8086:8086 \
-p 22022:22 \
Expand All @@ -44,7 +45,7 @@ docker start docker-statsd-influxdb-grafana
```
Host Container Service
3003 9000 grafana
3003 3003 grafana
8086 8086 influxdb
3004 8083 influxdb-admin
8125 8125 statsd
Expand All @@ -68,19 +69,21 @@ Password: root

### Add data source on Grafana

1. Open `Data Sources` from left side menu, then click on `Add data source`
1. Using the wizard click on `Add data source`
2. Choose a `name` for the source and flag it as `Default`
3. Choose `InfluxDB` as `type`
4. Choose `direct` as `access`
5. Fill remaining fields as follows and click on `Add` without altering other fields

```
Url: http://localhost:8086
Database: datasource
User: datasource
Password: datasource
Database: telegraf
User: telegraf
Password: telegraf
```

Basic auth and credentials must be left unflagged. Proxy is not required.

Now you are ready to add your first dashboard and launch some query on database.

## InfluxDB
Expand Down
11 changes: 11 additions & 0 deletions bash/profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi

mesg n

export HOME=/root
Loading

0 comments on commit ab9151a

Please sign in to comment.