Skip to content

Commit ad0791a

Browse files
committed
upgrade grafana to 1.9.1 and Graphite from the 0.9.x branch
1 parent e21f359 commit ad0791a

File tree

11 files changed

+1203
-129
lines changed

11 files changed

+1203
-129
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
logs

Dockerfile

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
FROM ubuntu:14.04
2-
RUN apt-get -y update
3-
RUN apt-get -y upgrade
4-
1+
FROM ubuntu:14.04.1
52

63
# ---------------- #
74
# Installation #
@@ -14,47 +11,43 @@ RUN apt-get -y update
1411
RUN apt-get -y install python-django-tagging python-simplejson python-memcache python-ldap python-cairo python-pysqlite2 python-support \
1512
python-pip gunicorn supervisor nginx-light nodejs git wget curl openjdk-7-jre build-essential python-dev
1613

17-
# Install Elasticsearch
18-
RUN cd ~ && wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.deb
19-
RUN cd ~ && dpkg -i elasticsearch-1.3.2.deb && rm elasticsearch-1.3.2.deb
20-
21-
# Install Whisper, Carbon and Graphite-Web
2214
RUN pip install Twisted==11.1.0
2315
RUN pip install Django==1.5
24-
RUN pip install whisper==0.9.12
25-
RUN pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-lib=/var/lib/graphite/lib" carbon==0.9.12
26-
RUN pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-lib=/var/lib/graphite/webapp" graphite-web==0.9.12
2716

2817

18+
# Install Elasticsearch
19+
RUN cd ~ && wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.deb
20+
RUN cd ~ && dpkg -i elasticsearch-1.3.2.deb && rm elasticsearch-1.3.2.deb
2921

30-
# --------------------------------------- #
31-
# Install & Patch StatsD and Grafana #
32-
# --------------------------------------- #
22+
# Checkout the stable branches of Graphite, Carbon and Whisper and install from there
23+
RUN mkdir /src
24+
RUN git clone https://github.com/graphite-project/whisper.git /src/whisper &&\
25+
cd /src/whisper &&\
26+
git checkout 0.9.x &&\
27+
python setup.py install
3328

34-
# We are patching StatsD and Grafana to play nice with url-encoded metric names, that makes the dashboard more usable when displaying
35-
# metrics names for actors, http traces and dispatchers.
29+
RUN git clone https://github.com/graphite-project/carbon.git /src/carbon &&\
30+
cd /src/carbon &&\
31+
git checkout 0.9.x &&\
32+
python setup.py install
3633

37-
# Install & Patch StatsD
38-
RUN mkdir /src &&\
39-
git clone https://github.com/etsy/statsd.git /src/statsd &&\
40-
cd /src/statsd &&\
41-
git checkout v0.7.2 &&\
42-
sed -i -e "s|.replace(/\[^a-zA-Z_\\\\-0-9\\\\.]/g, '');|.replace(/[^a-zA-Z_\\\\-0-9\\\\.\\\\%]/g, '');|" /src/statsd/stats.js
4334

35+
RUN git clone https://github.com/graphite-project/graphite-web.git /src/graphite-web &&\
36+
cd /src/graphite-web &&\
37+
git checkout 0.9.x &&\
38+
python setup.py install
4439

45-
# Install & Patch Grafana
46-
RUN mkdir /src/grafana &&\
47-
git clone https://github.com/grafana/grafana.git /src/grafana &&\
48-
cd /src/grafana &&\
49-
git checkout v1.7.0
40+
# Install StatsD
41+
RUN git clone https://github.com/etsy/statsd.git /src/statsd &&\
42+
cd /src/statsd &&\
43+
git checkout v0.7.2
5044

51-
ADD ./grafana/correctly-show-urlencoded-metrics.patch /src/grafana/correctly-show-urlencoded-metrics.patch
52-
RUN git apply /src/grafana/correctly-show-urlencoded-metrics.patch --directory=/src/grafana &&\
53-
cd /src/grafana &&\
54-
npm install &&\
55-
npm install -g grunt-cli &&\
56-
grunt build
5745

46+
# Install Grafana
47+
RUN mkdir /src/grafana
48+
RUN wget http://grafanarel.s3.amazonaws.com/grafana-1.9.1.tar.gz -O /src/grafana.tar.gz &&\
49+
tar -xzf /src/grafana.tar.gz -C /src/grafana --strip-components=1 &&\
50+
rm /src/grafana.tar.gz
5851

5952

6053
# ----------------- #
@@ -70,28 +63,30 @@ RUN mkdir -p /tmp/elasticsearch && chown elasticsearch:elasticsearch /tmp/el
7063
ADD ./statsd/config.js /src/statsd/config.js
7164

7265
# Configure Whisper, Carbon and Graphite-Web
73-
ADD ./graphite/initial_data.json /var/lib/graphite/webapp/graphite/initial_data.json
74-
ADD ./graphite/local_settings.py /var/lib/graphite/webapp/graphite/local_settings.py
75-
ADD ./graphite/carbon.conf /var/lib/graphite/conf/carbon.conf
76-
ADD ./graphite/storage-schemas.conf /var/lib/graphite/conf/storage-schemas.conf
77-
ADD ./graphite/storage-aggregation.conf /var/lib/graphite/conf/storage-aggregation.conf
78-
RUN mkdir -p /var/lib/graphite/storage/whisper
79-
RUN touch /var/lib/graphite/storage/graphite.db /var/lib/graphite/storage/index
80-
RUN chown -R www-data /var/lib/graphite/storage
81-
RUN chmod 0775 /var/lib/graphite/storage /var/lib/graphite/storage/whisper
82-
RUN chmod 0664 /var/lib/graphite/storage/graphite.db
83-
RUN cd /var/lib/graphite/webapp/graphite && python manage.py syncdb --noinput
66+
ADD ./graphite/initial_data.json /opt/graphite/webapp/graphite/initial_data.json
67+
ADD ./graphite/local_settings.py /opt/graphite/webapp/graphite/local_settings.py
68+
ADD ./graphite/carbon.conf /opt/graphite/conf/carbon.conf
69+
ADD ./graphite/storage-schemas.conf /opt/graphite/conf/storage-schemas.conf
70+
ADD ./graphite/storage-aggregation.conf /opt/graphite/conf/storage-aggregation.conf
71+
RUN mkdir -p /opt/graphite/storage/whisper
72+
RUN touch /opt/graphite/storage/graphite.db /opt/graphite/storage/index
73+
RUN chown -R www-data /opt/graphite/storage
74+
RUN chmod 0775 /opt/graphite/storage /opt/graphite/storage/whisper
75+
RUN chmod 0664 /opt/graphite/storage/graphite.db
76+
RUN cd /opt/graphite/webapp/graphite && python manage.py syncdb --noinput
8477

8578
# Configure Grafana
86-
ADD ./grafana/config.js /src/grafana/dist/config.js
87-
ADD ./grafana/default-dashboard.json /src/grafana/dist/app/dashboards/default.json
79+
ADD ./grafana/config.js /src/grafana/config.js
80+
81+
# Add the default dashboards
82+
RUN mkdir /src/dashboards
83+
ADD ./grafana/dashboards/* /src/dashboards/
8884

8985
# Configure nginx and supervisord
9086
ADD ./nginx/nginx.conf /etc/nginx/nginx.conf
9187
ADD ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
9288

9389

94-
9590
# ---------------- #
9691
# Expose Ports #
9792
# ---------------- #
@@ -107,7 +102,6 @@ EXPOSE 8126
107102

108103

109104

110-
111105
# -------- #
112106
# Run! #
113107
# -------- #

grafana/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function (Settings) {
1616
},
1717

1818
// default start dashboard
19-
default_route: '/dashboard/file/default.json',
19+
default_route: '/dashboard/db/welcome',
2020

2121
// Elasticsearch index for storing dashboards
2222
grafana_index: "grafana-dash",

grafana/correctly-show-urlencoded-metrics.patch

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
var fs = require('fs');
2+
var http = require('http');
3+
4+
var args = process.argv.slice(2);
5+
6+
setTimeout( function() {
7+
args.forEach(function (file_name) {
8+
var dashboard_file = fs.readFileSync(file_name, "utf8");
9+
var dashboard_resource = '/elasticsearch/grafana-dash/dashboard/' + process.argv[2].split('.')[0];
10+
var dashboard = JSON.parse(dashboard_file);
11+
12+
http.get({
13+
host: 'localhost',
14+
path: dashboard_resource
15+
16+
}, function(response) {
17+
var body = '';
18+
response.on('data', function(d) {
19+
body += d;
20+
});
21+
response.on('end', function() {
22+
var search_result = JSON.parse(body);
23+
if(!search_result.found) {
24+
var dashboard_data = {
25+
user: 'guest',
26+
group: 'guest',
27+
title: dashboard.title,
28+
tags: [],
29+
dashboard: JSON.stringify(dashboard)
30+
}
31+
32+
var put_request = http.request({
33+
host: 'localhost',
34+
path: dashboard_resource,
35+
method: 'PUT'
36+
})
37+
38+
put_request.write(JSON.stringify(dashboard_data));
39+
put_request.end();
40+
41+
console.log('Added the [' + dashboard.title + '] dashboard.');
42+
} else {
43+
console.log('Dashboard [' + dashboard.title + '] was already present.');
44+
}
45+
46+
});
47+
})
48+
})
49+
}, 20000);
50+
51+
52+
53+
// Starting the web server just to keep the process running.
54+
http.createServer(function (req, res) {
55+
res.writeHead(200, {'Content-Type': 'text/plain'});
56+
res.end('You should not talk to me!\n');
57+
}).listen(1337, '127.0.0.1');

0 commit comments

Comments
 (0)