graphite-project/docker-graphite-statsd

Name: docker-graphite-statsd

Owner: Graphite Project

Description: Official Docker image for Graphite

Forked from: hopsoft/docker-graphite-statsd

Created: 2017-07-18 14:59:15.0

Updated: 2018-05-22 10:58:42.0

Pushed: 2018-05-10 12:09:39.0

Homepage:

Size: 167

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This repo was based on @hopsoft's docker-graphite-statsd docker image and was used as base for “official” Graphite docker image with his permission. Also, it contains parts of famous @obfuscurity's synthesize Graphite installer. Thanks a lot, Nathan and Jason!

Any suggestions / patches etc. are welcome!

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
er run -d\
ame graphite\
estart=always\
80:80\
2003-2004:2003-2004\
2023-2024:2023-2024\
8125:8125/udp\
8126:8126\
phiteapp/graphite-statsd

This starts a Docker container named: graphite

Please also note that you can freely remap container port to any host port in case of corresponding port is already occupied on host. It's also not mandatory to map all ports, map only required ports - please see table below.

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

Includes the following components
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 8080 | 8080 | Graphite internal gunicorn port (without Nginx proxying). 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.

Please also note that you can freely remap container port to any host port in case of corresponding port is already occupied on host.

Mounted Volumes

Host | Container | Notes —————– | ————————– | ——————————- DOCKER ASSIGNED | /opt/graphite/conf | graphite config DOCKER ASSIGNED | /opt/graphite/storage | graphite stats storage DOCKER ASSIGNED | /opt/graphite/webapp/graphite/functions/custom | graphite custom functions dir 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.

Start Using Graphite & Statsd
Send Some Stats

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

e 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.

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.

hInterval: 10000

Ensure that storage-schemas.conf retentions are no finer grained than 10 seconds.

]
ern = .*
ntions = 5s:12h # WRONG
ntions = 10s:12h # OK
ntions = 60s:12h # OK
Statsd Admin Management Interface

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

ow all current counters
 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.

er run -d\
ame graphite\
estart=always\
/path/to/graphite/configs:/opt/graphite/conf\
/path/to/graphite/data:/opt/graphite/storage\
/path/to/statsd:/opt/statsd\
phiteapp/graphite-statsd

Note: The container will initialize properly if you mount empty volumes at

      `/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:

er run -d\
ame graphite\
estart=always\
80:80\
2003-2004:2003-2004\
2023-2024:2023-2024\
8125:8125/udp\
8126:8126\
"MEMCACHE_HOST=127.0.0.1:11211"\  # Memcached host. Separate by comma more than one servers.
"CACHE_DURATION=60"\              # in seconds
phiteapp/graphite-statsd

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

MEMCACHE_HOST=127.0.0.1:11211,10.0.0.1:11211"
Running through docker-compose

The following command will start the graphite statsd container through docker-compose

er-compose up
Additional Reading
Contributors

Build the image yourself.

  1. git clone https://github.com/graphite-project/docker-graphite-statsd.git
  2. docker build -t graphiteapp/graphite-statsd .

Alternate versions can be specified via --build-arg:

Alternate repositories can also be specified with the build args graphite_repo, carbon_repo, whisper_repo & statsd_repo.

To build an image from latest graphite, whisper & carbon master, run:

docker build -t graphiteapp/graphite-statsd . --build-arg version=master

To build an image using a fork of graphite-web, run:

docker build -t forked/graphite-statsd . --build-arg version=master --build-arg graphite_repo=https://github.com/forked/graphite-web.git


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.