From 4f31fbc02665e8971cd8a0fc03ce883ac09ff0de Mon Sep 17 00:00:00 2001 From: mishaschwartz <4380924+mishaschwartz@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:36:54 -0400 Subject: [PATCH 01/11] log exporter code --- .../config/proxy/docker-compose-extra.yml | 13 ++++ .../config/thredds/docker-compose-extra.yml | 5 ++ .../config/thredds/prometheus-log-exporter.py | 44 +++++++++++++ .../prometheus-log-parser/default.env | 11 ++++ .../docker-compose-extra.yml | 24 +++++++ .../prometheus-log-parser/entrypoint.sh | 5 ++ .../prometheus-log-exporter.py | 65 +++++++++++++++++++ .../prometheus-log-parser/requirements.txt | 2 + 8 files changed, 169 insertions(+) create mode 100644 birdhouse/optional-components/prometheus-log-parser/config/proxy/docker-compose-extra.yml create mode 100644 birdhouse/optional-components/prometheus-log-parser/config/thredds/docker-compose-extra.yml create mode 100644 birdhouse/optional-components/prometheus-log-parser/config/thredds/prometheus-log-exporter.py create mode 100644 birdhouse/optional-components/prometheus-log-parser/default.env create mode 100644 birdhouse/optional-components/prometheus-log-parser/docker-compose-extra.yml create mode 100644 birdhouse/optional-components/prometheus-log-parser/entrypoint.sh create mode 100644 birdhouse/optional-components/prometheus-log-parser/prometheus-log-exporter.py create mode 100644 birdhouse/optional-components/prometheus-log-parser/requirements.txt diff --git a/birdhouse/optional-components/prometheus-log-parser/config/proxy/docker-compose-extra.yml b/birdhouse/optional-components/prometheus-log-parser/config/proxy/docker-compose-extra.yml new file mode 100644 index 000000000..0b0308c40 --- /dev/null +++ b/birdhouse/optional-components/prometheus-log-parser/config/proxy/docker-compose-extra.yml @@ -0,0 +1,13 @@ +version: "3.4" +services: + proxy: + volumes: + - proxy-logs:${PROXY_LOG_DIR} + prometheus-log-parser: + volumes: + - proxy-logs:/var/log/proxy + environment: + - PROXY_LOG_FILE=${PROXY_LOG_FILE} + +volumes: + proxy-logs: diff --git a/birdhouse/optional-components/prometheus-log-parser/config/thredds/docker-compose-extra.yml b/birdhouse/optional-components/prometheus-log-parser/config/thredds/docker-compose-extra.yml new file mode 100644 index 000000000..0b344f0f8 --- /dev/null +++ b/birdhouse/optional-components/prometheus-log-parser/config/thredds/docker-compose-extra.yml @@ -0,0 +1,5 @@ +version: "3.4" +services: + prometheus-log-parser: + volumes: + - ./optional-components/prometheus-log-parser/config/thredds/prometheus-log-exporter.py:${PROMETHEUS_LOG_PARSER_EXPORTERS_DIR}/thredds-prometheus-log-exporter.py:ro diff --git a/birdhouse/optional-components/prometheus-log-parser/config/thredds/prometheus-log-exporter.py b/birdhouse/optional-components/prometheus-log-parser/config/thredds/prometheus-log-exporter.py new file mode 100644 index 000000000..cb9fa5aba --- /dev/null +++ b/birdhouse/optional-components/prometheus-log-parser/config/thredds/prometheus-log-exporter.py @@ -0,0 +1,44 @@ +import os +import re + +import prometheus_client + + +# This matches a request to the THREDDS data services as defined in birdhouse/components/thredds/catalog.xml.template +THREDDS_REQ_URI_REGEX = r'\/[^\s]+\/thredds\/(?PdodsC|fileServer|ncss)\/(?P[^\s]*)(?:\?(?P\w+))?' + +# This matches the nginx log_fomat as defined in birdhouse/components/proxy/nginx.conf.template +REGEX = re.compile( + r'(?P(?:^|\b(?-|[a-z_][a-z0-9_]{0,30})\s' + r'(?P\[(?P\d\d\d\d-\d\d-\d\d)T(?P