diff --git a/Dockerfile b/Dockerfile
index e172fb2..23f713e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,7 +7,7 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
-RUN apt-get update && apt-get install -yq git apache2 npm nodejs-legacy ruby
+RUN apt-get update && apt-get install -yq git apache2 npm nodejs-legacy ruby curl
RUN npm install -g grunt-cli bower
RUN gem install sass
RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/run/sshd
@@ -17,6 +17,7 @@ ADD container/000-default.conf etc/apache2/sites-enabled/000-default.conf
ADD container/ports.conf etc/apache2/ports.conf
RUN a2enmod proxy
RUN a2enmod proxy_http
+RUN a2enmod headers
# configure script
ADD container/configure.sh /configure.sh
@@ -35,6 +36,12 @@ ENV BANSHO_PROD true
ENV BANSHO_SURVEIL_URL http://surveil:8080/
ENV BANSHO_AUTH_URL http://surveil:8080/v2/auth/
+ENV INFLUXDB_HOST influxdb
+ENV INFLUXDB_PORT 8086
+ENV INFLUXDB_NAME db
+ENV INFLUXDB_USER root
+ENV INFLUXDB_PASS root
+
CMD ./configure.sh && \
cd /opt/bansho && \
bash -c "if [ $BANSHO_PROD = true ] ; then grunt production ; fi" && \
diff --git a/Makefile b/Makefile
index e162fe7..0da1aff 100644
--- a/Makefile
+++ b/Makefile
@@ -9,17 +9,17 @@ rebuild:
sudo docker build --no-cache -t bansho .
interactive:
- sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/app:/opt/bansho/dist -e BANSHO_ENV=false -i -t --name bansho bansho bash
+ sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil --link surveil_grafana_1:grafana -v $(shell pwd)/app:/opt/bansho/dist -e BANSHO_ENV=false -i -t --name bansho bansho bash
daemon:
- sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/app:/opt/bansho/dist -e BANSHO_PROD=false -d -t --name bansho bansho
+ sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil --link surveil_grafana_1:grafana -v $(shell pwd)/app:/opt/bansho/dist -e BANSHO_PROD=false -d -t --name bansho bansho
grunt development
production:
- sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -d -t --name bansho bansho
+ sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil --link surveil_grafana_1:grafana -d -t --name bansho bansho
staging:
- sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil -v $(shell pwd)/dist:/opt/bansho/dist -e BANSHO_PROD=false -d -t --name bansho bansho
+ sudo docker run -p 8888:8888 --link surveil_surveil_1:surveil --link surveil_grafana_1:grafana -v $(shell pwd)/dist:/opt/bansho/dist -e BANSHO_PROD=false -d -t --name bansho bansho
grunt staging
kill:
diff --git a/app/app.js b/app/app.js
index a47fe0d..5a88474 100644
--- a/app/app.js
+++ b/app/app.js
@@ -18,7 +18,8 @@ angular.module('bansho', [
'bansho.view.host',
'bansho.view.service',
'bansho.view.drupalDashboard',
- 'bansho.view.drupal'
+ 'bansho.view.drupal',
+ 'bansho.grafana'
])
.config(['$routeProvider', function ($routeProvider) {
diff --git a/app/components/grafana/grafana.js b/app/components/grafana/grafana.js
new file mode 100644
index 0000000..f4e3e21
--- /dev/null
+++ b/app/components/grafana/grafana.js
@@ -0,0 +1,23 @@
+'use strict';
+
+angular.module('bansho.grafana', [])
+ .service('iframeUrl', function () {
+ var createIFrameUrl = function (templateName, host_name, service_description, metric) {
+ return '/grafana/dashboard-solo/db/' + templateName + '?' +
+ 'panelId=' + '1' +
+ '&fullscreen&from=' + 'now-6h' +
+ '&to=' + 'now' +
+ '&var-metric1=' + metric +
+ '&var-host_name=' + host_name +
+ '&var-service_description=' + service_description;
+ };
+
+ var getIFrameUrl = function (metric, host_name, service_description) {
+ return createIFrameUrl('templatehostnameservicedescriptiononemetric',
+ host_name, service_description, metric);
+ };
+
+ return {
+ getIFrameUrl: getIFrameUrl
+ };
+ });
\ No newline at end of file
diff --git a/app/components/host/host_load/host_load.html b/app/components/host/host_load/host_load.html
index ded7d8c..de63822 100644
--- a/app/components/host/host_load/host_load.html
+++ b/app/components/host/host_load/host_load.html
@@ -1,5 +1,6 @@
Load
+
diff --git a/app/components/host/host_load/host_load.js b/app/components/host/host_load/host_load.js
index 38dc507..f7d2f29 100644
--- a/app/components/host/host_load/host_load.js
+++ b/app/components/host/host_load/host_load.js
@@ -1,12 +1,12 @@
'use strict';
angular.module('bansho.host.load', [])
- .directive('banshoHostLoad', function () {
+ .directive('banshoHostLoad', ['iframeUrl', function (iframeUrl) {
return {
restrict: 'E',
- compile: function (scope, element, attrs) {
- scope.host = attrs.host;
- },
+ controller: ['$scope', function ($scope, element, attrs) {
+ $scope.iframeUrl = iframeUrl.getIFrameUrl("metric_load1", $scope.host.config.host_name, "load");
+ }],
templateUrl: 'components/host/host_load/host_load.html'
};
- });
+ }]);
diff --git a/app/index.html b/app/index.html
index b9deb7d..3f2f5f9 100644
--- a/app/index.html
+++ b/app/index.html
@@ -69,6 +69,7 @@
+
diff --git a/container/000-default.conf b/container/000-default.conf
index 35976d8..3020ae8 100644
--- a/container/000-default.conf
+++ b/container/000-default.conf
@@ -15,6 +15,8 @@
ProxyPass /surveil/ http://surveil:8080/
ProxyPassReverse /surveil/ http://surveil:8080/
- ProxyPass /adagios/ http://demo.kaji-project.org/
- ProxyPassReverse /adagios/ http://demo.kaji-project.org/
+ RequestHeader set GRAFANA-USER "admin"
+ ProxyPass /grafana/ http://grafana:80/
+ ProxyPassReverse /grafana/ http://grafana:80/
+
diff --git a/container/configure.sh b/container/configure.sh
index 7b4ff57..5ba6e55 100755
--- a/container/configure.sh
+++ b/container/configure.sh
@@ -2,12 +2,33 @@
CONFIG_FILE="/etc/apache2/sites-enabled/000-default.conf"
-echo "=> Configuring apache ProxyPass ..."
+function configure_proxy {
+ echo "=> Configuring apache ProxyPass ..."
+
+ # Surveil URLS
+ sed -i "s|ProxyPass /surveil/ .*|ProxyPass /surveil/ ${BANSHO_SURVEIL_URL}|g" ${CONFIG_FILE}
+ sed -i "s|ProxyPassReverse /surveil/ .*|ProxyPassReverse /surveil/ ${BANSHO_SURVEIL_URL}|g" ${CONFIG_FILE}
+
+ # Bansho auth URL
+ sed -i "s|ProxyPass /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE}
+ sed -i "s|ProxyPassReverse /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE}
+}
+
+function configure_grafana {
+ echo "=> Configuring InfluxDB datasources."
+
+ curl 'http://localhost:8888/grafana/api/datasources' -X PUT -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"influxdb","type":"influxdb","url":"http://'${INFLUXDB_HOST}':'${INFLUXDB_PORT}'","access":"proxy","isDefault":true,"database":"'${INFLUXDB_NAME}'","user":"'${INFLUXDB_USER}'","password":"'${INFLUXDB_PASS}'"}'
+
+ # Save dashboard
+ curl 'http://localhost:8888/grafana/api/dashboards/db/' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary $'{"dashboard":{"id":null,"title":"templateHostNameServiceDescriptionOneMetric","originalTitle":"templateHostNameServiceDescriptionOneMetric","tags":[],"style":"dark","timezone":"browser","editable":true,"hideControls":false,"rows":[{"collapse":false,"editable":true,"height":"250px","panels":[{"aliasColors":{},"bars":false,"datasource":null,"editable":true,"error":false,"fill":1,"grid":{"leftLogBase":1,"leftMax":null,"leftMin":null,"rightLogBase":1,"rightMax":null,"rightMin":null,"threshold1":null,"threshold1Color":"rgba(216, 200, 27, 0.27)","threshold2":null,"threshold2Color":"rgba(234, 112, 112, 0.22)"},"id":1,"interval":"20s","legend":{"avg":false,"current":false,"max":false,"min":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":2,"links":[],"nullPointMode":"connected","percentage":false,"pointradius":5,"points":false,"renderer":"flot","seriesOverrides":[],"span":12,"stack":false,"steppedLine":false,"targets":[{"function":"mean","groupByTags":[],"measurement":"$metric1","query":"SELECT mean(value) FROM \\"$metric1\\" WHERE host_name=\'$host_name\' AND service_description=\'$service_description\' AND $timeFilter GROUP BY time($interval) ORDER BY asc","tags":[{"key":"host_name","value":"$host_name"},{"condition":"AND","key":"service_description","value":"$service_description"}]}],"timeFrom":null,"timeShift":null,"title":"","tooltip":{"shared":true,"value_type":"cumulative"},"type":"graph","x-axis":true,"y-axis":true,"y_formats":["short","short"]}],"title":"Row"}],"nav":[{"collapse":false,"enable":true,"notice":false,"now":true,"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"],"status":"Stable","time_options":["5m"],"type":"timepicker"}],"time":{"from":"now-6h","to":"now"},"templating":{"list":[{"allFormat":"glob","datasource":null,"includeAll":false,"multi":false,"multiFormat":"glob","name":"metric1","query":"SHOW measurements","refresh_on_load":false,"type":"query"},{"allFormat":"glob","datasource":null,"includeAll":false,"multi":false,"multiFormat":"glob","name":"host_name","query":"SHOW tag values With key in (host_name) ","refresh_on_load":false,"type":"query"},{"allFormat":"glob","datasource":null,"includeAll":false,"multi":false,"multiFormat":"glob","name":"service_description","query":"SHOW tag values With key in (service_description) ","refresh_on_load":false,"type":"query"}]},"annotations":{"list":[]},"schemaVersion":6,"version":0,"links":[]},"overwrite":true}' --compressed
+}
+
+configure_proxy
+
+if [ -f "/.grafana_setup" ]; then
+ echo "=> Data sources had been created before, skipping ..."
+else
+ (sleep 60 && configure_grafana && touch "/.grafana_setup")&
+fi
-# Surveil URLS
-sed -i "s|ProxyPass /surveil/ .*|ProxyPass /surveil/ ${BANSHO_SURVEIL_URL}|g" ${CONFIG_FILE}
-sed -i "s|ProxyPassReverse /surveil/ .*|ProxyPassReverse /surveil/ ${BANSHO_SURVEIL_URL}|g" ${CONFIG_FILE}
-# Bansho auth URL
-sed -i "s|ProxyPass /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE}
-sed -i "s|ProxyPassReverse /surveil/v2/auth/.*|ProxyPass /surveil/v2/auth/ ${BANSHO_AUTH_URL}|g" ${CONFIG_FILE}