Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #46 from obfuscurity/feature/graphite-master
Browse files Browse the repository at this point in the history
WIP Graphite 1.0
  • Loading branch information
obfuscurity authored Apr 11, 2017
2 parents 1262986 + 66effd5 commit 98404ca
Show file tree
Hide file tree
Showing 8 changed files with 806 additions and 57 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ Installing Graphite doesn't have to be difficult. The `install` script in synthe

Synthesize is built to run on Ubuntu 14.04 LTS. It will __not__ run on other Ubuntu releases or Linux distributions. The goal of this project is not to become an automation alternative to modern configuration management utilities (e.g. Chef or Puppet), but rather, to make it as easy as possible for the beginner Graphite user to get started and familiar with the project without having to learn a suite of other automation and/or infrastructure-related projects.

The resulting Graphite server __listens only on https port 443__ and has been configured to collect metrics specifically for helping profile the performance of your Graphite and Carbon services. It uses memcached for improved query performance, and Statsite for a fast, C-based implementation of the StatsD collector/aggregator.
The resulting Graphite web interface __listens only on https port 443__ and has been configured to collect metrics specifically for helping profile the performance of your Graphite and Carbon services. It uses memcached for improved query performance, and Statsite for a fast, C-based implementation of the StatsD collector/aggregator.

Beginning with version 3.0.0 we've also incorporated the Grafana dashboard project, a modern and full-featured alternative to Graphite's built-in Composer and Dashboard interfaces. It also includes a default dashboard for monitoring Carbon's internal statistics.

:warning: **WARNING:** You should not install Synthesize directly on your personal development system. It's strongly suggested that you use a VM or other temporary VPS instance for sandboxing Synthesize.

## Provides

* Graphite 0.9.15 ([graphite-web](https://github.com/graphite-project/graphite-web), [carbon](https://github.com/graphite-project/carbon), [whisper](https://github.com/graphite-project/whisper))
* Graphite 1.0.0 ([graphite-web](https://github.com/graphite-project/graphite-web), [carbon](https://github.com/graphite-project/carbon), [whisper](https://github.com/graphite-project/whisper))
* StatsD ([statsite](https://github.com/armon/statsite))
* collectd agent
* [Collectd](http://collectd.org/)
* [Grafana](https://grafana.org/)

## Dependencies

Expand All @@ -39,9 +42,11 @@ Synthesize configures the following host ports to forward to the private vagrant

```
config.vm.network :forwarded_port, guest: 443, host: 8443
config.vm.network :forwarded_port, guest: 8125, host: 8125
config.vm.network :forwarded_port, guest: 8125, host: 8125, protocol: 'tcp'
config.vm.network :forwarded_port, guest: 8125, host: 8125, protocol: 'udp'
config.vm.network :forwarded_port, guest: 2003, host: 22003
config.vm.network :forwarded_port, guest: 2004, host: 22004
config.vm.network :forwarded_port, guest: 3000, host: 3030
```

```
Expand All @@ -52,6 +57,8 @@ $ vagrant up

## Administration

### Graphite-Web

There is a superuser (Django) account that grants access to the administrative features in the backend Django database. The default credentials are:

* username `admin`
Expand All @@ -64,9 +71,18 @@ $ cd /opt/graphite/webapp/graphite
$ sudo python manage.py changepassword admin
```

### Grafana

Grafana includes a default user to start:

* username `admin`
* password `admin`

## Upgrade

It's now possible to upgrade an existing Synthesize (e.g. Graphite 0.9.12) to the newest Graphite 0.9.15. You will need to checkout at least version 2.3.0 of Synthesize for this feature. Besides upgrading the Graphite components, it will also migrate the webapp database (`graphite.db`) to the newest fixtures version.
:warning: **WARNING:** The following information is outdated for this experimental branch. If you attempt to run the upgrade script it will display a warning with further instructions to acknowledge the current experimental status and override the warning.

It's now possible to upgrade an existing Synthesize (e.g. Graphite 0.9.15) to the newest Graphite `HEAD`. Besides upgrading the Graphite components, it will also migrate the webapp database (`graphite.db`) to the newest fixtures version.

```
$ cd synthesize
Expand Down
3 changes: 2 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network :forwarded_port, guest: 8125, host: 8125, protocol: 'udp'
config.vm.network :forwarded_port, guest: 2003, host: 22003
config.vm.network :forwarded_port, guest: 2004, host: 22004
graphite_version = ENV['GRAPHITE_RELEASE'].nil? ? '0.9.15' : ENV['GRAPHITE_RELEASE']
config.vm.network :forwarded_port, guest: 3000, host: 3030
graphite_version = ENV['GRAPHITE_RELEASE'].nil? ? '1.0.0' : ENV['GRAPHITE_RELEASE']
config.vm.provision "shell", inline: "cd /vagrant; GRAPHITE_RELEASE=#{graphite_version} ./install"
end
24 changes: 20 additions & 4 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [[ ! $PYTHON_OPENSSL_INSTALLED == '' ]]; then
fi

if [ -z $GRAPHITE_RELEASE ]; then
GRAPHITE_RELEASE='0.9.15'
GRAPHITE_RELEASE='1.0.0'
fi

if [[ ! $UBUNTU_RELEASE =~ 'Ubuntu 14.04' ]]; then
Expand Down Expand Up @@ -100,29 +100,45 @@ cp ${SYNTHESIZE_HOME}/templates/graphite/webapp/* .
sed -i -e "s/UNSAFE_DEFAULT/`date | md5sum | cut -d ' ' -f 1`/" local_settings.py

# Setup the Django database
python manage.py syncdb --noinput
chown www-data:www-data ${GRAPHITE_STORAGE}/graphite.db
PYTHONPATH=${GRAPHITE_HOME}/webapp django-admin.py migrate --noinput --settings=graphite.settings --run-syncdb
PYTHONPATH=${GRAPHITE_HOME}/webapp django-admin.py loaddata --settings=graphite.settings initial_data.json

# Add carbon system user and set permissions
groupadd -g 998 carbon
useradd -c "carbon user" -g 998 -u 998 -s /bin/false carbon
chmod 775 ${GRAPHITE_STORAGE}
chown www-data:carbon ${GRAPHITE_STORAGE}
chown www-data:www-data ${GRAPHITE_STORAGE}/graphite.db
chown -R carbon ${GRAPHITE_STORAGE}/whisper
mkdir ${GRAPHITE_STORAGE}/log/apache2
chown www-data ${GRAPHITE_STORAGE}/log/webapp
chown -R www-data ${GRAPHITE_STORAGE}/log/webapp
chmod +x /etc/init.d/carbon-cache

# Setup hourly cron to rebuild Graphite index
cp ${SYNTHESIZE_HOME}/templates/graphite/cron/build-index /etc/cron.hourly/graphite-build-index
chmod 755 /etc/cron.hourly/graphite-build-index
sudo -u www-data /opt/graphite/bin/build-index.sh

# Install Grafana
echo 'deb https://packagecloud.io/grafana/stable/debian/ wheezy main' > /etc/apt/sources.list.d/grafana.list
curl https://packagecloud.io/gpg.key | apt-key add -
apt-get update -y
DEBIAN_FRONTEND=noninteractive apt-get install -y grafana
service grafana-server start
sleep 5
curl -X POST -H 'Content-Type: application/json' -u 'admin:admin' \
-d '{ "name": "graphite", "type": "graphite", "url": "https://127.0.0.1:443", "access": "proxy", "basicAuth": false }' \
"http://127.0.0.1:3000/api/datasources"
curl -X POST -H 'Content-Type: application/json' -u 'admin:admin' \
-d '{ "inputs": [{"name": "*", "pluginId": "graphite", "type": "datasource", "value": "graphite"}], "overwrite": true, "path": "dashboards/carbon_metrics.json", "pluginId": "graphite" }' \
"http://127.0.0.1:3000/api/dashboards/import"

# Start our processes
update-rc.d carbon-cache defaults
service carbon-cache start
service memcached start
service collectd start
service apache2 start
service statsite start
service apache2 restart

25 changes: 2 additions & 23 deletions templates/graphite/conf/graphite.wsgi
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
import os, sys
import sys
sys.path.append('/opt/graphite/webapp')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'graphite.settings')

import django

if django.VERSION < (1, 4):
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
else:
# From 1.4 wsgi support was improved and since 1.7 old style WSGI script
# causes AppRegistryNotReady exception
# https://docs.djangoproject.com/en/dev/releases/1.7/#wsgi-scripts
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()


# READ THIS
# Initializing the search index can be very expensive, please include
# the WSGIImportScript directive pointing to this script in your vhost
# config to ensure the index is preloaded before any requests are handed
# to the process.
from graphite.logger import log
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search
from graphite.wsgi import application
Loading

0 comments on commit 98404ca

Please sign in to comment.