├── storage-schemas.conf ├── initial_data.json ├── supervisord.conf ├── local_settings.py ├── Dockerfile ├── nginx.conf ├── README.md └── carbon.conf /storage-schemas.conf: -------------------------------------------------------------------------------- 1 | [carbon] 2 | pattern = ^carbon\..* 3 | retentions = 1m:31d,10m:1y,1h:5y 4 | 5 | [default] 6 | pattern = .* 7 | retentions = 10s:8d,1m:31d,10m:1y,1h:5y 8 | -------------------------------------------------------------------------------- /initial_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "pk": 1, 4 | "model": "auth.user", 5 | "fields": { 6 | "username": "admin", 7 | "first_name": "", 8 | "last_name": "", 9 | "is_active": true, 10 | "is_superuser": true, 11 | "is_staff": true, 12 | "last_login": "2011-09-20 17:02:14", 13 | "groups": [], 14 | "user_permissions": [], 15 | "password": "sha1$1b11b$edeb0a67a9622f1f2cfeabf9188a711f5ac7d236", 16 | "email": "root@example.com", 17 | "date_joined": "2011-09-20 17:02:14" 18 | } 19 | } 20 | ] 21 | -------------------------------------------------------------------------------- /supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon = true 3 | environment = GRAPHITE_STORAGE_DIR='/var/lib/graphite/storage',GRAPHITE_CONF_DIR='/var/lib/graphite/conf' 4 | 5 | [program:nginx] 6 | command = /usr/sbin/nginx 7 | stdout_logfile = /var/log/supervisor/%(program_name)s.log 8 | stderr_logfile = /var/log/supervisor/%(program_name)s.log 9 | autorestart = true 10 | 11 | [program:carbon-cache] 12 | user = www-data 13 | command = /var/lib/graphite/bin/carbon-cache.py --debug start 14 | stdout_logfile = /var/log/supervisor/%(program_name)s.log 15 | stderr_logfile = /var/log/supervisor/%(program_name)s.log 16 | autorestart = true 17 | 18 | [program:graphite-webapp] 19 | user = www-data 20 | directory = /var/lib/graphite/webapp 21 | environment = PYTHONPATH='/var/lib/graphite/webapp' 22 | command = /usr/bin/gunicorn_django -b127.0.0.1:8000 -w2 graphite/settings.py 23 | stdout_logfile = /var/log/supervisor/%(program_name)s.log 24 | stderr_logfile = /var/log/supervisor/%(program_name)s.log 25 | autorestart = true 26 | -------------------------------------------------------------------------------- /local_settings.py: -------------------------------------------------------------------------------- 1 | # Edit this file to override the default graphite settings, do not edit settings.py 2 | 3 | # Turn on debugging and restart apache if you ever see an "Internal Server Error" page 4 | #DEBUG = True 5 | 6 | # Set your local timezone (django will try to figure this out automatically) 7 | TIME_ZONE = 'UTC' 8 | 9 | # Setting MEMCACHE_HOSTS to be empty will turn off use of memcached entirely 10 | #MEMCACHE_HOSTS = ['127.0.0.1:11211'] 11 | 12 | # Sometimes you need to do a lot of rendering work but cannot share your storage mount 13 | #REMOTE_RENDERING = True 14 | #RENDERING_HOSTS = ['fastserver01','fastserver02'] 15 | #LOG_RENDERING_PERFORMANCE = True 16 | #LOG_CACHE_PERFORMANCE = True 17 | 18 | # If you've got more than one backend server they should all be listed here 19 | #CLUSTER_SERVERS = [] 20 | 21 | # Override this if you need to provide documentation specific to your graphite deployment 22 | #DOCUMENTATION_URL = "http://wiki.mycompany.com/graphite" 23 | 24 | # Enable email-related features 25 | #SMTP_SERVER = "mail.mycompany.com" 26 | 27 | # LDAP / ActiveDirectory authentication setup 28 | #USE_LDAP_AUTH = True 29 | #LDAP_SERVER = "ldap.mycompany.com" 30 | #LDAP_PORT = 389 31 | #LDAP_SEARCH_BASE = "OU=users,DC=mycompany,DC=com" 32 | #LDAP_BASE_USER = "CN=some_readonly_account,DC=mycompany,DC=com" 33 | #LDAP_BASE_PASS = "readonly_account_password" 34 | #LDAP_USER_QUERY = "(username=%s)" #For Active Directory use "(sAMAccountName=%s)" 35 | 36 | # If sqlite won't cut it, configure your real database here (don't forget to run manage.py syncdb!) 37 | #DATABASE_ENGINE = 'mysql' # or 'postgres' 38 | #DATABASE_NAME = 'graphite' 39 | #DATABASE_USER = 'graphite' 40 | #DATABASE_PASSWORD = 'graphite-is-awesome' 41 | #DATABASE_HOST = 'mysql.mycompany.com' 42 | #DATABASE_PORT = '3306' 43 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | from ubuntu:14.04 2 | run echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty universe' >> /etc/apt/sources.list 3 | run apt-get -y update 4 | 5 | # Install required packages 6 | run apt-get -y install python-ldap python-cairo python-django python-twisted python-django-tagging python-simplejson python-memcache python-pysqlite2 python-support python-tz python-pip gunicorn supervisor nginx-light 7 | run pip install whisper==0.9.15 8 | run pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-lib=/var/lib/graphite/lib" carbon==0.9.15 9 | run pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-lib=/var/lib/graphite/webapp" graphite-web==0.9.15 10 | 11 | # Add system service config 12 | add ./nginx.conf /etc/nginx/nginx.conf 13 | add ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf 14 | 15 | # Add graphite config 16 | add ./initial_data.json /var/lib/graphite/webapp/graphite/initial_data.json 17 | add ./local_settings.py /var/lib/graphite/webapp/graphite/local_settings.py 18 | add ./carbon.conf /var/lib/graphite/conf/carbon.conf 19 | add ./storage-schemas.conf /var/lib/graphite/conf/storage-schemas.conf 20 | run mkdir -p /var/lib/graphite/storage/whisper 21 | run touch /var/lib/graphite/storage/graphite.db /var/lib/graphite/storage/index 22 | run chown -R www-data /var/lib/graphite/storage 23 | run chmod 0775 /var/lib/graphite/storage /var/lib/graphite/storage/whisper 24 | run chmod 0664 /var/lib/graphite/storage/graphite.db 25 | run cd /var/lib/graphite/webapp/graphite && python manage.py syncdb --noinput 26 | 27 | # Nginx 28 | expose 80 29 | # Carbon line receiver port 30 | expose 2003 31 | # Carbon UDP receiver port 32 | expose 2003/udp 33 | # Carbon pickle receiver port 34 | expose 2004 35 | # Carbon cache query port 36 | expose 7002 37 | 38 | cmd ["/usr/bin/supervisord"] 39 | 40 | # vim:ts=8:noet: 41 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | daemon off; 2 | user www-data; 3 | worker_processes 1; 4 | pid /var/run/nginx.pid; 5 | 6 | events { 7 | worker_connections 1024; 8 | } 9 | 10 | http { 11 | sendfile on; 12 | tcp_nopush on; 13 | tcp_nodelay on; 14 | keepalive_timeout 65; 15 | types_hash_max_size 2048; 16 | server_tokens off; 17 | 18 | server_names_hash_bucket_size 32; 19 | 20 | include /etc/nginx/mime.types; 21 | default_type application/octet-stream; 22 | 23 | access_log /var/log/nginx/access.log; 24 | error_log /var/log/nginx/error.log; 25 | 26 | gzip on; 27 | gzip_disable "msie6"; 28 | 29 | server { 30 | listen 80 default_server; 31 | server_name _; 32 | 33 | open_log_file_cache max=1000 inactive=20s min_uses=2 valid=1m; 34 | 35 | location / { 36 | proxy_pass http://127.0.0.1:8000; 37 | proxy_set_header X-Real-IP $remote_addr; 38 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 39 | proxy_set_header X-Forwarded-Proto $scheme; 40 | proxy_set_header X-Forwarded-Server $host; 41 | proxy_set_header X-Forwarded-Host $http_host; 42 | proxy_set_header Host $http_host; 43 | 44 | client_max_body_size 10m; 45 | client_body_buffer_size 128k; 46 | 47 | proxy_connect_timeout 90; 48 | proxy_send_timeout 90; 49 | proxy_read_timeout 90; 50 | 51 | proxy_buffer_size 4k; 52 | proxy_buffers 4 32k; 53 | proxy_busy_buffers_size 64k; 54 | proxy_temp_file_write_size 64k; 55 | } 56 | 57 | add_header Access-Control-Allow-Origin "*"; 58 | add_header Access-Control-Allow-Methods "GET, OPTIONS"; 59 | add_header Access-Control-Allow-Headers "origin, authorization, accept"; 60 | 61 | location /content { 62 | alias /var/lib/graphite/webapp/content; 63 | } 64 | 65 | location /media { 66 | alias /usr/share/pyshared/django/contrib/admin/media; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Graphite + Carbon 2 | 3 | An all-in-one image running graphite and carbon-cache. **Version**: 0.9.12. 4 | 5 | This image contains a sensible default configuration of graphite and 6 | carbon-cache. Starting this container will, by default, bind the the following 7 | host ports: 8 | 9 | - `80`: the graphite web interface 10 | - `2003`: the carbon-cache line receiver (the standard graphite protocol) 11 | - `2004`: the carbon-cache pickle receiver 12 | - `7002`: the carbon-cache query port (used by the web interface) 13 | 14 | With this image, you can get up and running with graphite by simply running: 15 | 16 | docker run -d nickstenning/graphite 17 | 18 | If you already have services running on the host on one or more of these ports, 19 | you may wish to allow docker to assign random ports on the host. You can do this 20 | easily by running: 21 | 22 | docker run -p 80 -p 2003 -p 2004 -p 7002 -d nickstenning/graphite 23 | 24 | You can log into the administrative interface of graphite-web (a Django 25 | application) with the username `admin` and password `admin`. These passwords can 26 | be changed through the web interface. 27 | 28 | **N.B.** Please be aware that by default docker will make the exposed ports 29 | accessible from anywhere if the host firewall is unconfigured. 30 | 31 | ### Data volumes 32 | 33 | Graphite data is stored at `/var/lib/graphite/storage/whisper` within the 34 | container. If you wish to store your metrics outside the container (highly 35 | recommended) you can use docker's data volumes feature. For example, to store 36 | graphite's metric database at `/data/graphite` on the host, you could use: 37 | 38 | docker run -v /data/graphite:/var/lib/graphite/storage/whisper \ 39 | -d nickstenning/graphite 40 | 41 | **N.B.** You will need to run the container with suitable permissions to write 42 | to the data volume directory. Carbon and the graphite webapp run as `www-data` 43 | inside the container, but this UID/GID may be mapped inconsistently on the host. 44 | 45 | ### Technical details 46 | 47 | By default, this instance of carbon-cache uses the following retention periods 48 | resulting in whisper files of approximately 2.5MiB. 49 | 50 | 10s:8d,1m:31d,10m:1y,1h:5y 51 | 52 | For more information, see [the 53 | repository](https://github.com/nickstenning/dockerfiles/tree/master/graphite). 54 | -------------------------------------------------------------------------------- /carbon.conf: -------------------------------------------------------------------------------- 1 | [cache] 2 | LOCAL_DATA_DIR = /var/lib/graphite/storage/whisper/ 3 | 4 | # Specify the user to drop privileges to 5 | # If this is blank carbon runs as the user that invokes it 6 | # This user must have write access to the local data directory 7 | USER = 8 | 9 | # Limit the size of the cache to avoid swapping or becoming CPU bound. 10 | # Sorts and serving cache queries gets more expensive as the cache grows. 11 | # Use the value "inf" (infinity) for an unlimited cache size. 12 | MAX_CACHE_SIZE = inf 13 | 14 | # Limits the number of whisper update_many() calls per second, which effectively 15 | # means the number of write requests sent to the disk. This is intended to 16 | # prevent over-utilizing the disk and thus starving the rest of the system. 17 | # When the rate of required updates exceeds this, then carbon's caching will 18 | # take effect and increase the overall throughput accordingly. 19 | MAX_UPDATES_PER_SECOND = 1000 20 | 21 | # Softly limits the number of whisper files that get created each minute. 22 | # Setting this value low (like at 50) is a good way to ensure your graphite 23 | # system will not be adversely impacted when a bunch of new metrics are 24 | # sent to it. The trade off is that it will take much longer for those metrics' 25 | # database files to all get created and thus longer until the data becomes usable. 26 | # Setting this value high (like "inf" for infinity) will cause graphite to create 27 | # the files quickly but at the risk of slowing I/O down considerably for a while. 28 | MAX_CREATES_PER_MINUTE = inf 29 | 30 | LINE_RECEIVER_INTERFACE = 0.0.0.0 31 | LINE_RECEIVER_PORT = 2003 32 | 33 | ENABLE_UDP_LISTENER = True 34 | UDP_RECEIVER_INTERFACE = 0.0.0.0 35 | UDP_RECEIVER_PORT = 2003 36 | 37 | PICKLE_RECEIVER_INTERFACE = 0.0.0.0 38 | PICKLE_RECEIVER_PORT = 2004 39 | 40 | CACHE_QUERY_INTERFACE = 0.0.0.0 41 | CACHE_QUERY_PORT = 7002 42 | 43 | LOG_UPDATES = False 44 | 45 | # Enable AMQP if you want to receve metrics using an amqp broker 46 | # ENABLE_AMQP = False 47 | 48 | # Verbose means a line will be logged for every metric received 49 | # useful for testing 50 | # AMQP_VERBOSE = False 51 | 52 | # AMQP_HOST = localhost 53 | # AMQP_PORT = 5672 54 | # AMQP_VHOST = / 55 | # AMQP_USER = guest 56 | # AMQP_PASSWORD = guest 57 | # AMQP_EXCHANGE = graphite 58 | 59 | # Patterns for all of the metrics this machine will store. Read more at 60 | # http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol#Bindings 61 | # 62 | # Example: store all sales, linux servers, and utilization metrics 63 | # BIND_PATTERNS = sales.#, servers.linux.#, #.utilization 64 | # 65 | # Example: store everything 66 | # BIND_PATTERNS = # 67 | 68 | # NOTE: you cannot run both a cache and a relay on the same server 69 | # with the default configuration, you have to specify a distinict 70 | # interfaces and ports for the listeners. 71 | 72 | [relay] 73 | LINE_RECEIVER_INTERFACE = 0.0.0.0 74 | LINE_RECEIVER_PORT = 2003 75 | 76 | PICKLE_RECEIVER_INTERFACE = 0.0.0.0 77 | PICKLE_RECEIVER_PORT = 2004 78 | 79 | CACHE_SERVERS = server1, server2, server3 80 | MAX_QUEUE_SIZE = 10000 81 | --------------------------------------------------------------------------------