diff --git a/wis2-gdc-api/Dockerfile b/wis2-gdc-api/Dockerfile index 3c8370f..95b123f 100644 --- a/wis2-gdc-api/Dockerfile +++ b/wis2-gdc-api/Dockerfile @@ -28,7 +28,7 @@ ENV PYGEOAPI_OPENAPI=/pygeoapi/local.openapi.yml RUN apt-get update && \ apt-get install -y curl && \ - pip3 install pywcmp && \ + pip3 install -r requirements.txt && \ pywcmp bundle sync COPY ./wis2-gdc-api.yml /pygeoapi/local.config.yml diff --git a/wis2-gdc-api/app.py b/wis2-gdc-api/app.py index 60d0d27..1a67daf 100644 --- a/wis2-gdc-api/app.py +++ b/wis2-gdc-api/app.py @@ -21,8 +21,9 @@ import os -from flask import Flask, send_file +from flask import Flask, Response, send_file from pygeoapi.flask_app import BLUEPRINT as pygeoapi_blueprint +import requests app = Flask(__name__, static_url_path='/static') app.url_map.strict_slashes = False @@ -50,9 +51,10 @@ def archive(): @app.route('/wis2-gdc-metrics.txt') def metrics(): - metrics_file = os.environ.get('WIS2_GDC_OPENMETRICS_FILE') + collector_url = os.environ.get('WIS2_GDC_COLLECTOR_URL') try: - return send_file(metrics_file, mimetype='text/plain') - except FileNotFoundError: - return 'Not Found', 404 + response = requests.get(collector_url).text + return Response(response, mimetype='text/plain') + except Exception: + return 'Internal Server Error', 500 diff --git a/wis2-gdc-api/requirements.txt b/wis2-gdc-api/requirements.txt new file mode 100644 index 0000000..dc457db --- /dev/null +++ b/wis2-gdc-api/requirements.txt @@ -0,0 +1,2 @@ +pywis-pubsub +requests diff --git a/wis2-gdc.env b/wis2-gdc.env index 0c8dc1f..4a9bae9 100644 --- a/wis2-gdc.env +++ b/wis2-gdc.env @@ -5,6 +5,7 @@ export WIS2_GDC_BACKEND_TYPE=Elasticsearch export WIS2_GDC_BACKEND_CONNECTION=http://elasticsearch:9200/wis2-discovery-metadata export WIS2_GDC_BROKER_URL=mqtt://wis2-gdc:wis2-gdc@wis2-gdc-broker:1883 export WIS2_GDC_CENTRE_ID=ca-eccc-msc-global-discovery-catalogue +export WIS2_GDC_COLLECTOR_URL=http://wis2-gdc-metrics-collector:8006 export WIS2_GDC_GB=mqtts://everyone:everyone@globalbroker.meteo.fr:8883 export WIS2_GDC_GB_TOPIC=origin/a/wis2/+/metadata/# export WIS2_GDC_METADATA_ARCHIVE_ZIPFILE=/data/wis2-gdc-archive.zip