Skip to content

Commit

Permalink
Merge pull request #311 from idealista/develop
Browse files Browse the repository at this point in the history
Develop to Master add Metrics for uWSGI mode.
  • Loading branch information
santi-eidu authored Sep 30, 2022
2 parents 2a1cb07 + 0517475 commit a9898c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).

## [Unreleased](https://github.com/idealista/prom2teams/tree/develop)
## [4.1.0](https://github.com/idealista/prom2teams/tree/4.1.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/4.0.0...4.1.0)
### Fixed
- *[#309](https://github.com/idealista/prom2teams/pull/309) Update prom2teams to use flask exporter with uWSGI for metrics when using uWSGI mode* @santi-eidu
## [4.0.0](https://github.com/idealista/prom2teams/tree/4.0.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/3.3.0...4.0.0)
### Fixed
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN apk add gcc libc-dev yaml-dev linux-headers --no-cache \
FROM python:3.8-alpine
LABEL maintainer="[email protected]"
EXPOSE 8089
EXPOSE 9090
WORKDIR /opt/prom2teams
COPY docker/rootfs .
COPY --from=builder /prom2teams/dist .
Expand All @@ -23,6 +24,7 @@ RUN apk add gcc libc-dev yaml-dev linux-headers pcre pcre-dev --no-cache \
RUN addgroup -g "101" -S prom2teams && \
adduser -S prom2teams -G prom2teams -u "101" && \
mkdir -p /var/log/prom2teams && \
mkdir -p /opt/prom2teams/metrics && \
chown -R prom2teams:prom2teams /var/log/prom2teams && \
chown -R prom2teams:prom2teams /opt/prom2teams
USER prom2teams
Expand All @@ -37,5 +39,8 @@ ENV PROM2TEAMS_PORT="8089" \
UWSGI_THREADS="1" \
UWSGI_PORT="8089" \
UWSGI_HOST="0.0.0.0" \
UWSGI_PROTOCOL="http"
UWSGI_PROTOCOL="http" \
PROMETHEUS_MULTIPROC_PORT="9090" \
PROMETHEUS_MULTIPROC_DIR="/opt/prom2teams/metrics" \
prometheus_multiproc_dir="/opt/prom2teams/metrics"
ENTRYPOINT ["sh", "prom2teams_start.sh"]
1 change: 1 addition & 0 deletions bin/prom2teams
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ except ImportError:
from prom2teams.app.api import app as application

if __name__ == "__main__":
application.config['ENV'] = "werkzeug"
host = application.config['HOST']
port = int(application.config['PORT'])
run_simple(hostname=host, port=port, application=application, use_reloader=True,
Expand Down
10 changes: 7 additions & 3 deletions prom2teams/app/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,13 @@ def config_app(application):
application.config['GROUP_ALERTS_BY'] = command_line_args.groupalertsby
if command_line_args.enablemetrics or os.environ.get('PROM2TEAMS_PROMETHEUS_METRICS', False):
os.environ["DEBUG_METRICS"] = "True"
from prometheus_flask_exporter import PrometheusMetrics
metrics = PrometheusMetrics(application)

if application.config['ENV'] == "werkzeug":
from prometheus_flask_exporter import PrometheusMetrics
metrics = PrometheusMetrics(application)
else:
from prometheus_flask_exporter.multiprocess import UWsgiPrometheusMetrics
metrics = UWsgiPrometheusMetrics(application)
metrics.start_http_server(int(os.getenv('PROMETHEUS_MULTIPROC_PORT')))
if 'MICROSOFT_TEAMS' not in application.config:
raise MissingConnectorConfigKeyException('missing connector key in config')

Expand Down

0 comments on commit a9898c8

Please sign in to comment.