Skip to content

Commit

Permalink
feat: LOG_LEVEL env, bump poetry version, other small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmix committed Apr 28, 2023
1 parent c6cde78 commit bdd9766
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /app

RUN python -m venv venv && \
pip install --no-cache-dir poetry==1.4.1
pip install --no-cache-dir poetry==1.4.2

COPY pyproject.toml poetry.lock ./

Expand Down
14 changes: 12 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from prometheus_client import CollectorRegistry, push_to_gateway
from urllib.parse import urljoin

logging.basicConfig(level='INFO')

PUSHGATEWAY_URL = os.environ.get('PUSHGATEWAY_URL', 'http://pushgateway:9091')
PUSHGATEWAY_BASIC_AUTH_USERNAME = os.environ.get(
Expand All @@ -30,6 +29,12 @@

JOB_PREFIX = os.environ.get('JOB_PREFIX', 'env')

LOG_LEVEL = os.environ.get('LOG_LEVEL', 'INFO')

logging.basicConfig(level=LOG_LEVEL)

logging.info(f'Gate UP!')


def project_containers():
'''
Expand Down Expand Up @@ -88,7 +93,11 @@ def push_gateway_handler(url, method, timeout, headers, data):

while True:
time.sleep(SCRAPE_INTERVAL)
for container in project_containers():
containers = project_containers()
if len(containers) == 0:
logging.info('There are no project containers')
continue
for container in containers:
# --- specify the metrics url
port, path = get_container_scrape_params(container)
url = urljoin(f'http://{container.name}:{port}', path)
Expand All @@ -102,3 +111,4 @@ def push_gateway_handler(url, method, timeout, headers, data):
job=f'{JOB_PREFIX}-{container.name}',
registry=registry,
handler=push_gateway_handler)

3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ services:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./:/app
environment:
JOB_PREFIX: prod
JOB_PREFIX: test
# LOG_LEVEL: INFO
# # --- push metrics to pushgateway with auth
# PUSHGATEWAY_URL: http://pc-ip-address:19091
# PUSHGATEWAY_BASIC_AUTH_USERNAME: admin
Expand Down
3 changes: 3 additions & 0 deletions tmuxp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

exec tmuxp load ./tmuxp.yaml

0 comments on commit bdd9766

Please sign in to comment.