Public | Automated Build

Last pushed: 8 days ago
Short Description
Short description is empty for this repo.
Full Description

Docker Image for Graphite & Statsd

Get Graphite & Statsd running instantly

Graphite & Statsd can be complex to setup.
This image will have you running & collecting stats in just a few minutes.

Quick Start

docker run -d\
 --name graphite\
 --restart=always\
 -p 80:80\
 -p 2003-2004:2003-2004\
 -p 2023-2024:2023-2024\
 -p 8125:8125/udp\
 -p 8126:8126\
 hopsoft/graphite-statsd

This starts a Docker container named: graphite

That's it, you're done ... almost.

Includes the following components

  • Nginx - reverse proxies the graphite dashboard
  • Graphite - front-end dashboard
  • Carbon - back-end
  • Statsd - UDP based back-end proxy

Mapped Ports

Host Container Service
80 80 nginx
2003 2003 carbon receiver - plaintext
2004 2004 carbon receiver - pickle
2023 2023 carbon aggregator - plaintext
2024 2024 carbon aggregator - pickle
8125 8125 statsd
8126 8126 statsd admin

By default, statsd listens on the UDP port 8125. If you want it to listen on the TCP port 8125 instead, you can set the environment variable STATSD_INTERFACE to tcp when running the container.

Mounted Volumes

Host Container Notes
DOCKER ASSIGNED /opt/graphite/conf graphite config
DOCKER ASSIGNED /opt/graphite/storage graphite 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

Base Image

Built using Phusion's base image.

  • All Graphite related processes are run as daemons & monitored with runit.
  • Includes additional services such as logrotate.

Start Using Graphite & Statsd

Send Some Stats

Let's fake some stats with a random counter to prove things are working.

while true; do echo -n "example:$((RANDOM % 100))|c" | nc -w 1 -u 127.0.0.1 8125; done

Visualize the Data

Open Graphite in a browser.

Secure the Django Admin

Update the default Django admin user account. The default is insecure.

  • username: root
  • password: root
  • email: root.graphite@mailinator.com

First login at: http://localhost/account/login
Then update the root user's profile at: http://localhost/admin/auth/user/1/

Change the Configuration

Read up on Graphite's post-install tasks.
Focus on the storage-schemas.conf.

  1. Stop the container docker stop graphite.
  2. Find the configuration files on the host by inspecting the container docker inspect graphite.
  3. Update the desired config files.
  4. 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/.


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

Statsd Admin Management Interface

A management interface (default on port 8126) allows you to manage statsd & retrieve stats.

# show all current counters
echo counters | nc localhost 8126

More info & additional commands.

A Note on Volumes

You may find it useful to mount explicit volumes so configs & data can be managed from a known location on the host.

Simply specify the desired volumes when starting the container.

docker run -d\
 --name graphite\
 --restart=always\
 -v /path/to/graphite/configs:/opt/graphite/conf\
 -v /path/to/graphite/data:/opt/graphite/storage\
 -v /path/to/statsd:/opt/statsd\
 hopsoft/graphite-statsd

Note: The container will initialize properly if you mount empty volumes at
/opt/graphite, /opt/graphite/conf, /opt/graphite/storage, or /opt/statsd

Memcached config

If you have a Memcached server running, and want to Graphite use it, you can do it using environment variables, like this:

docker run -d\
 --name graphite\
 --restart=always\
 -p 80:80\
 -p 2003-2004:2003-2004\
 -p 2023-2024:2023-2024\
 -p 8125:8125/udp\
 -p 8126:8126\
 -e "MEMCACHE_HOST=127.0.0.1:11211"\  # Memcached host. Separate by comma more than one servers.
 -e "CACHE_DURATION=60"\              # in seconds
 hopsoft/graphite-statsd

Also, you can specify more than one memcached server, using commas:

-e "MEMCACHE_HOST=127.0.0.1:11211,10.0.0.1:11211"

Additional Reading

Contributors

Build the image yourself.

  1. git clone https://github.com/hopsoft/docker-graphite-statsd.git
  2. docker build -t hopsoft/graphite-statsd .
Docker Pull Command
Owner
hopsoft
Source Repository

Comments (11)
tabber
a year ago

First off, thank you very much for putting this together. This has been invaluable in getting up and going with Graphite and metrics work.

I'm wondering if you're going to be adding the nginx django admin to the image soon.

hopsoft
a year ago

I'll take care of the tag as soon as I can. I'm currently moving across country but will tag once settled. Thank you for the reminder.

therealcspeckrb
a year ago

Could you please add a docker hub tag to the current release (e.g. 0.9.18-phusion) and to future releases? Some Docker SASS providers do not support pinning images by their sha256 digest, latest changes on every build and all the other tags here are from nine months ago and don't reflect the updates and great work you've done on this since then. Thanks

nkuhn
a year ago

When we mounted /opt/graphite/storage carbon didn't come up because it's PID file was located in /opt/graphite/storage folder. We fixed that in just mounting /opt/graphite/storage/whisper.

prgmerror
2 years ago

After installation I view the docker container logs and noticed this error message:

Error: Cannot find module '/opt/statsd/stats.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3

is stats.js not provided in this installation?

asafmesika
2 years ago

Couple of actions I had to do to get it working:

  • In docker run command, I changed the mount command
    -v /home/ubuntu/graphite/storage:/opt/graphite/storage \
    -v /home/ubuntu/log:/var/log \
    
    If you mount /opt/graphite, it essentially overrides the directory inside docker there by failing the start script on file not found
  • I also created the following directories on my host machine (which are mounted), since without them the start script of docker threw file not found exceptions
    mkdir -p /home/ubuntu/log/nginx
    mkdir -p /home/ubuntu/log/graphite
    

Finally after trying to run

echo "local.random.diceroll 4 `date +%s`" | nc -q0 0.0.0.0 2003

to test drive it and nothing showed up on graphite-web, I had to run

docker stop graphite
docker start graphite

and then the nc command worked and I saw the point I sent in graphite web

hopsoft
2 years ago

@mirstan, I have plans to revisit & get this working soon. I currently have 2 pull requests that address this issue, but I need tweak the solution a bit before I'm happy with it. Thanks.

mirstan
2 years ago

Same issue as @blos when I follow your instructions to mount /var/log -- graphite web won't come up.

blos
3 years ago

Noticed that if you mount the /var/log outside, the graphite web interface won't start, python blurts out message that it can't find the /var/log/graphite/info.lof

hopsoft
3 years ago

I just updated the image to use runit for process supervision.