From 1aec132a29ab3007143602eab3200ba98f4352a3 Mon Sep 17 00:00:00 2001 From: Roman Vynar Date: Tue, 26 Jul 2016 21:46:01 +0300 Subject: [PATCH] Made docker logs clean, added METRICS_RESOLUTION var. --- CHANGELOG.md | 4 ++-- Dockerfile | 12 +++++------- add-grafana-datasource.sh | 4 ++++ docker-compose.yml | 1 + nginx.conf | 1 + supervisord.conf | 30 ++++++++++++++++++++++++------ 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d59e2ab86..d2bc33883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Dockerfile b/Dockerfile index abd83cec7..833ee228b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ # ####### # @@ -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 # @@ -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"] diff --git a/add-grafana-datasource.sh b/add-grafana-datasource.sh index 76d9e179b..983eb02a7 100755 --- a/add-grafana-datasource.sh +++ b/add-grafana-datasource.sh @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 68842498a..955f3699c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,3 +23,4 @@ services: # environment: # - METRICS_RETENTION=720h # - METRICS_MEMORY=262144 +# - METRICS_RESOLUTION=1s diff --git a/nginx.conf b/nginx.conf index c2c997026..4bceb8072 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,6 +1,7 @@ user www-data; worker_processes 4; pid /run/nginx.pid; +daemon off; events { worker_connections 768; diff --git a/supervisord.conf b/supervisord.conf index fdc2830b7..790821966 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -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 @@ -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 @@ -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