From 3c9ef24e4667a4ef6e93925cd3513840104c7f0f Mon Sep 17 00:00:00 2001 From: Marcelo R Costa Date: Tue, 12 Jan 2021 17:20:28 -0600 Subject: [PATCH] task(observability): Enable UWSGI status endpoint and metrics for multiple workers (#301) * task(observability): Adopt new base image * enable uwsgi status endpoint to export metrics through sidecar later * adding config to track metrics for different worker pids * correct name of the folder * add logrotate (it was supposed to be available on the parent img) --- Dockerfile | 5 +++-- clear_prometheus_multiproc | 7 +++++++ deployment/uwsgi/uwsgi.ini | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100755 clear_prometheus_multiproc diff --git a/Dockerfile b/Dockerfile index c26e96ca..bc0321ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # To run: docker run -v /path/to/wsgi.py:/var/www/indexd/wsgi.py --name=indexd -p 81:80 indexd # To check running container: docker exec -it indexd /bin/bash -FROM quay.io/cdis/python-nginx:pybase3-1.4.1 +FROM quay.io/cdis/python-nginx:pybase3-1.4.2 ENV appname=indexd @@ -9,11 +9,12 @@ ENV appname=indexd RUN apk update \ && apk add postgresql-libs postgresql-dev libffi-dev libressl-dev \ && apk add linux-headers musl-dev gcc \ - && apk add curl bash git vim + && apk add curl bash git vim logrotate COPY . /$appname COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini COPY ./deployment/uwsgi/wsgi.py /$appname/wsgi.py +COPY clear_prometheus_multiproc /$appname/clear_prometheus_multiproc WORKDIR /$appname RUN python -m pip install --upgrade pip \ diff --git a/clear_prometheus_multiproc b/clear_prometheus_multiproc new file mode 100755 index 00000000..eb03b942 --- /dev/null +++ b/clear_prometheus_multiproc @@ -0,0 +1,7 @@ +#!/bin/bash +set -ex + +rm -Rf $1 +mkdir $1 +chmod 755 $1 +chown 100:101 $1 diff --git a/deployment/uwsgi/uwsgi.ini b/deployment/uwsgi/uwsgi.ini index 662beb76..3d46220a 100644 --- a/deployment/uwsgi/uwsgi.ini +++ b/deployment/uwsgi/uwsgi.ini @@ -21,6 +21,10 @@ wsgi-file=/indexd/wsgi.py plugins = python3 vacuum = true pythonpath = /indexd/ +stats = 127.0.0.1:9191 +stats-http = true +env = prometheus_multiproc_dir=/var/tmp/uwsgi_flask_metrics +exec-asap = /indexd/clear_prometheus_multiproc /var/tmp/uwsgi_flask_metrics # Initialize application in worker processes, not master. This prevents the # workers from all trying to open the same database connections at startup. lazy = true