Graphite & Statsd can be complex to setup. This image will have you running & collecting stats in just a few minutes.
sudo docker run -d \
--name graphite \
-p 80:80 \
-p 2003:2003 \
-p 8125:8125/udp \
hopsoft/graphite-statsd
This starts a Docker container named: graphite
That's it, you're done ... almost.
- Nginx - reverse proxies the graphite dashboard
- Graphite - front-end dashboard
- Carbon - back-end
- Statsd - UDP based back-end proxy
Host | Container | Service |
---|---|---|
80 | 80 | nginx |
2003 | 2003 | carbon |
8125 | 8125 | statsd |
Host | Container | Notes |
---|---|---|
DOCKER ASSIGNED | /opt/graphite | graphite config & stats storage |
DOCKER ASSIGNED | /etc/nginx | nginx config |
DOCKER ASSIGNED | /opt/statsd | statsd config |
DOCKER ASSIGNED | /etc/logrotate.d | logrotate config |
DOCKER ASSIGNED | /var/log | log files |
Built using Phusion's base image.
- All Graphite related processes are run as daemons & monitored with runit.
- Includes additional services such as logrotate.
Let's fake some stats with a random counter to prove things are working.
while true
do
echo -n "example.statsd.counter.changed:$(((RANDOM % 10) + 1))|c" | nc -w 1 -u localhost 8125
done
<CTL-C>
Open Graphite in a browser at http://localhost/dashboard.
Update the default Django admin user account. The default is insecure.
- username: root
- password: root
- email: [email protected]
First login at: http://localhost/account/login Then update the root user's profile at: http://localhost/admin/auth/user/1/
The image contains a set of default configuration files: https://github.com/hopsoft/docker-graphite-statsd/tree/master/conf
If we want to make changes to these configuration files, we have two options:
- Stop the container
docker stop graphite
. - Find the configuration files on the host by inspecting the container
docker inspect graphite
. - Update the desired config files. Note: If the config files are updated by the image, you need to change them in
/conf-default
and not in the target destination (like /opt/graphite...) - Restart the container
docker start graphite
.
Note: If you change settings in /opt/graphite/conf/storage-schemas.conf
be sure to delete the old whisper files under /opt/graphite/storage/whisper/
.
The image contains a volume /conf-custom that will be scanned for configuration files. If files exist, they will replace any default files contained in the image. Note that the path of the file needs to correspond to the path of the default config files in the image (check out https://github.com/hopsoft/docker-graphite-statsd/tree/master/conf). An example:
- Create a config directory in the host, e.g.
mkdir /myConf
- Add the config files that we want to overwrite, e.g.
mkdir /myConf/graphite; vi /myConf/graphite/storage-schemas.conf
- Run the container with the /config-custom volume mounted:
sudo docker run -d --name graphite -v /myConf:/conf-custom hopsoft/graphite-statsd
- The init scripts will automatically replace the
storage-schemas.conf
config file with our custom config file
Custom config files can also be changed (or added) for a running container. In this case, we need to restart the container: sudo docker restart graphite
Read up on Graphite's post-install tasks. Focus on the storage-schemas.conf
Important: Ensure your Statsd flush interval is at least as long as the highest-resolution retention.
For example, if /opt/statsd/config.js
looks like this.
flushInterval: 10000
Ensure that storage-schemas.conf
retentions are no finer grained than 10 seconds.
[all]
pattern = .*
retentions = 5s:12h # WRONG
retentions = 10s:12h # OK
retentions = 60s:12h # OK
If running this image on cloud infrastructure such as AWS,
you should consider mounting /opt/graphite
& /var/log
on a larger volume.
-
Configure the host to mount a large EBS volume.
-
Specify the volume mounts when starting the container.
sudo docker run -d \ --name graphite \ -v /path/to/ebs/graphite:/opt/graphite \ -v /path/to/ebs/log:/var/log \ -p 80:80 \ -p 2003:2003 \ -p 8125:8125/udp \ hopsoft/graphite-statsd
- Introduction to Docker
- Official Statsd Documentation
- Practical Guide to StatsD/Graphite Monitoring
- Configuring Graphite for StatsD
Build the image yourself.
git clone https://github.com/hopsoft/docker-graphite-statsd.git
cd docker-graphite-statsd
vagrant up
vagrant ssh
sudo docker build -t hopsoft/graphite-statsd /vagrant
Note: Pay attention to the forwarded ports in the Vagrantfile.
git clone https://github.com/hopsoft/docker-graphite-statsd.git
sudo docker build -t hopsoft/graphite-statsd ./docker-graphite-statsd