Skip to content

Commit

Permalink
Made docker logs clean, added METRICS_RESOLUTION var.
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-vynar committed Jul 26, 2016
1 parent 16bc830 commit 1aec132
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Percona Monitoring and Management (PMM) Server

v1.0.2 unreleased 2016-07-22
v1.0.2 released 2016-07-28

* Grafana 3.1.0.
* Prometheus 1.0.0.
* Prometheus 1.0.1.
* Set default metrics retention to 30 days.
* Eliminated port 9001. Now the container uses only one configurable port, 80 by default.
* Eliminated the need to specify ADDRESS variable when creating docker container.
Expand Down
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ RUN apt-get -y update && apt-get install -y \
# Prometheus #
# ########## #

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

# ####### #
Expand All @@ -43,9 +43,7 @@ RUN git clone https://github.com/Percona-Lab/grafana_mongodb_dashboards.git && \
COPY grafana.ini /etc/grafana/grafana.ini
COPY add-grafana-datasource.sh /opt
RUN chgrp grafana /etc/grafana/grafana.ini && \
/opt/add-grafana-datasource.sh && \
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 && \
sed -i 's/,range_input/.replace(\/"{\/g,"\\"").replace(\/}"\/g,"\\""),range_input/; s/step_input:""/step_input:this.target.step/' /usr/share/grafana/public/app/plugins/datasource/prometheus/query_ctrl.js
/opt/add-grafana-datasource.sh

# ####################### #
# Percona Query Analytics #
Expand Down Expand Up @@ -89,5 +87,5 @@ COPY landing-page/ /opt/landing-page/
# Run everything with supervisor #
# ############################## #

COPY supervisord.conf /etc/supervisor/conf.d/pmm.conf
CMD ["supervisord"]
COPY supervisord.conf /etc/supervisor/supervisord.conf
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
4 changes: 4 additions & 0 deletions add-grafana-datasource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ for i in `seq 30`; do
sleep 1
fi
done

# 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 && \
sed -i 's/,range_input/.replace(\/"{\/g,"\\"").replace(\/}"\/g,"\\""),range_input/; s/step_input:""/step_input:this.target.step/' /usr/share/grafana/public/app/plugins/datasource/prometheus/query_ctrl.js
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ services:
# environment:
# - METRICS_RETENTION=720h
# - METRICS_MEMORY=262144
# - METRICS_RESOLUTION=1s
1 change: 1 addition & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;

events {
worker_connections 768;
Expand Down
30 changes: 24 additions & 6 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
[unix_http_server]
file=/var/run/supervisor.sock
chmod=0700
username = dummy
password = dummy

[supervisord]
pidfile = /var/run/supervisord.pid
logfile = /var/log/supervisord.log
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor
nodaemon = true

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
username = dummy
password = dummy

[program:mysql]
priority = 1
command = service mysql start
autorestart = false
command = /usr/bin/mysqld_safe
stdout_logfile = /var/log/mysqld.log
stderr_logfile = /var/log/mysqld.log
autorestart = true

[program:consul]
priority = 2
Expand Down Expand Up @@ -35,7 +52,7 @@ priority = 5
command = nginx
stdout_logfile = /var/log/nginx.log
stderr_logfile = /var/log/nginx.log
autorestart = false
autorestart = true

[program:cron]
priority = 6
Expand All @@ -46,7 +63,8 @@ autorestart = true

[program:prometheus]
priority = 7
command = bash -c "sleep 5 && /opt/prometheus/prometheus -config.file=/opt/prometheus/prometheus.yml -storage.local.path=/opt/prometheus/data -web.listen-address=:9090 -storage.local.retention=${METRICS_RETENTION:-720h} -storage.local.memory-chunks=${METRICS_MEMORY:-262144} -web.console.libraries=/opt/prometheus/console_libraries -web.console.templates=/opt/prometheus/consoles -web.external-url=http://localhost:9090/prometheus/"
# Sleep to wait for consul to start up.
command = bash -c "sleep 5 && replace 1s ${METRICS_RESOLUTION:-1s} -- /opt/prometheus/prometheus.yml && /opt/prometheus/prometheus -config.file=/opt/prometheus/prometheus.yml -storage.local.path=/opt/prometheus/data -web.listen-address=:9090 -storage.local.retention=${METRICS_RETENTION:-720h} -storage.local.memory-chunks=${METRICS_MEMORY:-262144} -web.console.libraries=/opt/prometheus/console_libraries -web.console.templates=/opt/prometheus/consoles -web.external-url=http://localhost:9090/prometheus/"
stdout_logfile = /var/log/prometheus.log
stderr_logfile = /var/log/prometheus.log
autorestart = true
Expand Down

0 comments on commit 1aec132

Please sign in to comment.