Add Grafana configuration to docker file and add graph
Change-Id: I687c1c24fed49a98f83015cab73879a3323432fb
This commit is contained in:
parent
bc2a419f53
commit
45aae4bf8a
@ -7,7 +7,7 @@ ENV LANG en_US.UTF-8
|
|||||||
ENV LANGUAGE en_US:en
|
ENV LANGUAGE en_US:en
|
||||||
ENV LC_ALL en_US.UTF-8
|
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 npm install -g grunt-cli bower
|
||||||
RUN gem install sass
|
RUN gem install sass
|
||||||
RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/run/sshd
|
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
|
ADD container/ports.conf etc/apache2/ports.conf
|
||||||
RUN a2enmod proxy
|
RUN a2enmod proxy
|
||||||
RUN a2enmod proxy_http
|
RUN a2enmod proxy_http
|
||||||
|
RUN a2enmod headers
|
||||||
|
|
||||||
# configure script
|
# configure script
|
||||||
ADD container/configure.sh /configure.sh
|
ADD container/configure.sh /configure.sh
|
||||||
@ -35,6 +36,12 @@ ENV BANSHO_PROD true
|
|||||||
ENV BANSHO_SURVEIL_URL http://surveil:8080/
|
ENV BANSHO_SURVEIL_URL http://surveil:8080/
|
||||||
ENV BANSHO_AUTH_URL http://surveil:8080/v2/auth/
|
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 && \
|
CMD ./configure.sh && \
|
||||||
cd /opt/bansho && \
|
cd /opt/bansho && \
|
||||||
bash -c "if [ $BANSHO_PROD = true ] ; then grunt production ; fi" && \
|
bash -c "if [ $BANSHO_PROD = true ] ; then grunt production ; fi" && \
|
||||||
|
8
Makefile
8
Makefile
@ -9,17 +9,17 @@ rebuild:
|
|||||||
sudo docker build --no-cache -t bansho .
|
sudo docker build --no-cache -t bansho .
|
||||||
|
|
||||||
interactive:
|
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:
|
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
|
grunt development
|
||||||
|
|
||||||
production:
|
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:
|
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
|
grunt staging
|
||||||
|
|
||||||
kill:
|
kill:
|
||||||
|
@ -18,7 +18,8 @@ angular.module('bansho', [
|
|||||||
'bansho.view.host',
|
'bansho.view.host',
|
||||||
'bansho.view.service',
|
'bansho.view.service',
|
||||||
'bansho.view.drupalDashboard',
|
'bansho.view.drupalDashboard',
|
||||||
'bansho.view.drupal'
|
'bansho.view.drupal',
|
||||||
|
'bansho.grafana'
|
||||||
])
|
])
|
||||||
|
|
||||||
.config(['$routeProvider', function ($routeProvider) {
|
.config(['$routeProvider', function ($routeProvider) {
|
||||||
|
23
app/components/grafana/grafana.js
Normal file
23
app/components/grafana/grafana.js
Normal file
@ -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
|
||||||
|
};
|
||||||
|
});
|
@ -1,5 +1,6 @@
|
|||||||
<div class="subcomponent__live subcomponent__small">
|
<div class="subcomponent__live subcomponent__small">
|
||||||
<h2>Load</h2>
|
<h2>Load</h2>
|
||||||
|
<iframe src="{{iframeUrl}}" width="450" height="200" frameborder="0"></iframe>
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('bansho.host.load', [])
|
angular.module('bansho.host.load', [])
|
||||||
.directive('banshoHostLoad', function () {
|
.directive('banshoHostLoad', ['iframeUrl', function (iframeUrl) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
compile: function (scope, element, attrs) {
|
controller: ['$scope', function ($scope, element, attrs) {
|
||||||
scope.host = attrs.host;
|
$scope.iframeUrl = iframeUrl.getIFrameUrl("metric_load1", $scope.host.config.host_name, "load");
|
||||||
},
|
}],
|
||||||
templateUrl: 'components/host/host_load/host_load.html'
|
templateUrl: 'components/host/host_load/host_load.html'
|
||||||
};
|
};
|
||||||
});
|
}]);
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
<script src="components/table/cell_status_host_address/cell_status_host_address.js"></script>
|
<script src="components/table/cell_status_host_address/cell_status_host_address.js"></script>
|
||||||
<script src="components/table/cell_status_host_status/cell_status_host_status.js"></script>
|
<script src="components/table/cell_status_host_status/cell_status_host_status.js"></script>
|
||||||
<script src="components/table/state_icon/state_icon.js"></script>
|
<script src="components/table/state_icon/state_icon.js"></script>
|
||||||
|
<script src="components/grafana/grafana.js"></script>
|
||||||
|
|
||||||
<script src="components/host/host.js"></script>
|
<script src="components/host/host.js"></script>
|
||||||
<script src="components/host/host_cpu/host_cpu.js"></script>
|
<script src="components/host/host_cpu/host_cpu.js"></script>
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
ProxyPass /surveil/ http://surveil:8080/
|
ProxyPass /surveil/ http://surveil:8080/
|
||||||
ProxyPassReverse /surveil/ http://surveil:8080/
|
ProxyPassReverse /surveil/ http://surveil:8080/
|
||||||
|
|
||||||
ProxyPass /adagios/ http://demo.kaji-project.org/
|
RequestHeader set GRAFANA-USER "admin"
|
||||||
ProxyPassReverse /adagios/ http://demo.kaji-project.org/
|
ProxyPass /grafana/ http://grafana:80/
|
||||||
|
ProxyPassReverse /grafana/ http://grafana:80/
|
||||||
|
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
@ -2,12 +2,33 @@
|
|||||||
|
|
||||||
CONFIG_FILE="/etc/apache2/sites-enabled/000-default.conf"
|
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}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user