Skip to content

Commit

Permalink
Added dashboards import instead of using JSON files.
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-vynar committed Aug 23, 2016
1 parent 2196c4a commit 1813447
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 321 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ v1.0.4 unreleased 2016-08-19
* added search by query fingerprint
* various fixes and improvements
* Added "MongoDB RocksDB" dashboard.
* Now you can save the predefined dashboards in-place.

v1.0.3 released 2016-08-05

Expand Down
75 changes: 34 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ RUN apt-get -y update && apt-get install -y \
nginx \
mysql-server \
python \
supervisor
python-requests \
supervisor && \
rm -f /etc/cron.daily/apt

# ########## #
# Prometheus #
# ########## #

ADD https://github.com/prometheus/prometheus/releases/download/v1.0.1/prometheus-1.0.1.linux-amd64.tar.gz /opt/
RUN mkdir prometheus && \
RUN curl -s -LO https://github.com/prometheus/prometheus/releases/download/v1.0.1/prometheus-1.0.1.linux-amd64.tar.gz && \
mkdir prometheus && \
tar xfz prometheus-1.0.1.linux-amd64.tar.gz --strip-components=1 -C prometheus
COPY prometheus.yml /opt/prometheus/

Expand All @@ -32,44 +34,21 @@ COPY prometheus.yml /opt/prometheus/
# ####### #

RUN 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 - && \
curl -s https://packagecloud.io/gpg.key | apt-key add - && \
apt-get -y update && \
apt-get -y install grafana
#RUN git clone https://github.com/percona/grafana-dashboards.git && \
# mkdir /var/lib/grafana/dashboards && \
# cp grafana-dashboards/dashboards/* /var/lib/grafana/dashboards/
#RUN git clone https://github.com/Percona-Lab/grafana_mongodb_dashboards.git && \
# cp grafana_mongodb_dashboards/dashboards/* /var/lib/grafana/dashboards/
RUN mkdir /var/lib/grafana/dashboards
COPY dashboards/*.json /var/lib/grafana/dashboards/
COPY grafana.ini /etc/grafana/grafana.ini
apt-get -y install grafana && \
git clone https://github.com/percona/grafana-dashboards.git && \
git clone -b alias2instance https://github.com/roman-vynar/grafana_mongodb_dashboards.git
COPY import-dashboards.py /opt
COPY grafana-postinstall.sh /opt
RUN /opt/grafana-postinstall.sh

# ####################### #
# Percona Query Analytics #
# ####################### #

ADD https://www.percona.com/downloads/TESTING/pmm/percona-qan-api-1.0.4-20160819.83525f0-x86_64.tar.gz \
https://www.percona.com/downloads/TESTING/pmm/percona-qan-app-1.0.4-20160819.815ca21.tar.gz \
/opt/
RUN mkdir qan-api && \
tar zxf percona-qan-api-1.0.4-20160819.83525f0-x86_64.tar.gz --strip-components=1 -C qan-api && \
mkdir qan-app && \
tar zxf percona-qan-app-1.0.4-20160819.815ca21.tar.gz --strip-components=1 -C qan-app
COPY qan-install.sh /opt
RUN /opt/qan-install.sh

COPY pt-archiver /usr/bin/
COPY purge-qan-data /etc/cron.daily
RUN rm /etc/cron.daily/apt

# ###### #
# Consul #
# ###### #

ADD https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip /opt/
RUN unzip consul_0.6.4_linux_amd64.zip && \
RUN curl -s -LO https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip && \
unzip consul_0.6.4_linux_amd64.zip && \
mkdir -p /opt/consul-data

# ##### #
Expand All @@ -80,17 +59,31 @@ COPY nginx.conf /etc/nginx
COPY nginx-ssl.conf /etc/nginx
RUN touch /etc/nginx/.htpasswd

# ############ #
# Landing page #
# ############ #
# ########################### #
# Supervisor and landing page #
# ########################### #

COPY landing-page/ /opt/landing-page/

# ############################## #
# Run everything with supervisor #
# ############################## #

COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY entrypoint.sh /opt

# ####################### #
# Percona Query Analytics #
# ####################### #

COPY pt-archiver /usr/bin/
COPY purge-qan-data /etc/cron.daily
COPY qan-install.sh /opt
ADD https://www.percona.com/downloads/TESTING/pmm/percona-qan-api-1.0.4-20160819.83525f0-x86_64.tar.gz \
https://www.percona.com/downloads/TESTING/pmm/percona-qan-app-1.0.4-20160819.815ca21.tar.gz \
/opt/
RUN mkdir qan-api && \
tar zxf percona-qan-api-1.0.4-20160819.83525f0-x86_64.tar.gz --strip-components=1 -C qan-api && \
mkdir qan-app && \
tar zxf percona-qan-app-1.0.4-20160819.815ca21.tar.gz --strip-components=1 -C qan-app && \
/opt/qan-install.sh

# ##### #
# Start #
# ##### #
CMD ["/opt/entrypoint.sh"]
12 changes: 1 addition & 11 deletions grafana-postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
#!/bin/bash

chgrp grafana /etc/grafana/grafana.ini
service grafana-server start

for i in `seq 30`; do
if curl -s http://admin:admin@localhost:3000/api/datasources; then
curl http://admin:admin@localhost:3000/api/datasources -X POST -H 'Content-Type: application/json' --data-binary '{"name":"Prometheus","type":"prometheus","url":"http://localhost:9090/prometheus/","access":"proxy","isDefault":true}'
echo "Added Prometheus data source to Grafana"
break
else
echo "Waiting for Grafana..."
sleep 1
fi
done
python /opt/import-dashboards.py

# Apply interval fix
sed -i 's/expr=\(.\)\.replace(\(.\)\.expr,\(.\)\.scopedVars\(.*\)var \(.\)=\(.\)\.interval/expr=\1.replace(\2.expr,\3.scopedVars\4var \5=\1.replace(\6.interval, \3.scopedVars)/' /usr/share/grafana/public/app/plugins/datasource/prometheus/datasource.js
Expand Down
Loading

0 comments on commit 1813447

Please sign in to comment.