Skip to content

Instantly share code, notes, and snippets.

@GaryRogers
Created October 2, 2014 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GaryRogers/0c5f4fa9baa0f3a45a76 to your computer and use it in GitHub Desktop.
Save GaryRogers/0c5f4fa9baa0f3a45a76 to your computer and use it in GitHub Desktop.
StatsD/CentOS Dockerfile
# Docker file to create a CentOS StatsD host.
# This uses Elasticsearch as a backend rather than Graphite/Carbon.
# Depends on having an Elasticsearch container.
FROM centos:centos6
MAINTAINER Gary Rogers <gary-rogers@uiowa.edu>
# Install things as root
USER root
RUN \
yum update -y --quiet && \
yum install -y --quiet wget && \
yum install -y --quiet tar && \
yum install -y --quiet unzip && \
yum install -y --quiet which && \
yum install -y --quiet git
# Add an statsd user that StatsD will actually run as.
RUN useradd statsd -c 'StatsD User' -d /home/statsd
# Set up /local for the ES binaries and data.
RUN \
mkdir -p /local/node && \
mkdir -p /local/statsd && \
chown statsd:statsd /local/statsd && \
mkdir -p /local/data && \
chown statsd:statsd /local/data
# Set some ENV variables to cut down on the typos.
ENV NODE_HOME /local/node
ENV NODE_VERSION 0.10.32
ENV PATH $NODE_HOME/bin:$PATH
ENV STATSD_HOME /local/statsd
ENV PATH $STATSD_HOME:$PATH
ENV STATSD_CONF /local/statsd/statsdConfig.js
ENV STATSD_VERSION 1.3.4
# Download and install Node
RUN \
cd /tmp && \
wget --quiet http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz && \
tar xfz node-v$NODE_VERSION-linux-x64.tar.gz && \
rm node-v$NODE_VERSION-linux-x64.tar.gz && \
mv /tmp/node-v$NODE_VERSION-linux-x64/* $NODE_HOME
# Download and install StatsD
RUN \
cd /tmp && \
wget --quiet https://github.com/etsy/statsd/archive/master.zip && \
unzip master.zip && \
rm master.zip && \
mv /tmp/statsd-master/* $STATSD_HOME && \
cd $STATSD_HOME && \
npm install git://github.com/markkimsal/statsd-elasticsearch-backend.git
VOLUME ["/local/data"]
# Setup our StatsD config
RUN \
touch $STATSD_CONF && \
printf "{\n" >> $STATSD_CONF && \
printf " port: 8125,\n" >> $STATSD_CONF && \
printf " elasticsearch: {\n" >> $STATSD_CONF && \
printf " port: 9200,\n" >> $STATSD_CONF && \
printf " host: \"elasticsearch\",\n" >> $STATSD_CONF && \
printf " path: \"/\",\n" >> $STATSD_CONF && \
printf " indexPrefix: \"statsd\",\n" >> $STATSD_CONF && \
printf " countType: \"counter\",\n" >> $STATSD_CONF && \
printf " timerType: \"timer\",\n" >> $STATSD_CONF && \
printf " timerDataType: \"timer_data\"\n" >> $STATSD_CONF && \
printf " }\n" >> $STATSD_CONF && \
printf "}\n" >> $STATSD_CONF
RUN \
touch $STATSD_HOME/statsd.sh && \
printf "#!/usr/bin/env bash\n" >> $STATSD_HOME/statsd.sh && \
printf "node \$STATSD_HOME/stats.js \$STATSD_CONF\n" && \
chmod +x $STATSD_HOME/statsd.sh
CMD ["statsd.sh"]
EXPOSE 8125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment