diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index e827afa16..1584a1f08 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -324,26 +324,6 @@ OK, go for it! Your Galaxy web site is available at: `http://localhost:8000 `_ using the admin user with -password ``admin``. Navigate to ``Galaxy Search Metrics - InfluxDB`` and -``Galaxy Search Metrics - Prometheus`` dashboards. - -Search metrics are exposed at `http://localhost:8000/metrics `_. From -there, the metrics are being scraped by Prometheus -(`http://localhost:9090/ `_). Prometheus serves as a short-term storage. -For a long-term metrics storage, the metrics are being sent from -Prometheus to InfluxDB. - Create an admin user ^^^^^^^^^^^^^^^^^^^^ diff --git a/galaxy/api/serializers/influx.py b/galaxy/api/serializers/influx.py index d944077ad..eeaf641d7 100644 --- a/galaxy/api/serializers/influx.py +++ b/galaxy/api/serializers/influx.py @@ -65,6 +65,9 @@ class BaseMeasurement(drf_serializers.Serializer): measurement = drf_serializers.CharField() def save(self): + if not settings.GALAXY_METRICS_ENABLED: + return + global influx_insert_buffer if len(influx_insert_buffer) < settings.INFLUX_INSERT_BUFFER_COUNT: influx_insert_buffer.append(self.data) diff --git a/galaxy/api/views/search.py b/galaxy/api/views/search.py index 4da17116e..c60f29a22 100644 --- a/galaxy/api/views/search.py +++ b/galaxy/api/views/search.py @@ -33,7 +33,6 @@ from galaxy.api import filters from galaxy.api import serializers from galaxy.api.views import base_views as base -from galaxy.common import metrics from galaxy.main import models __all__ = [ @@ -80,7 +79,6 @@ def get_queryset(self): repository__provider_namespace__namespace__active=True)) # TODO(cutwater): Use serializer to parse request arguments - @metrics.send('search') def list(self, request, *args, **kwargs): queryset = self.filter_queryset(self.get_queryset()) diff --git a/galaxy/common/metrics.py b/galaxy/common/metrics.py deleted file mode 100644 index aea1eb9ae..000000000 --- a/galaxy/common/metrics.py +++ /dev/null @@ -1,95 +0,0 @@ -# (c) 2012-2018, Ansible by Red Hat -# -# This file is part of Ansible Galaxy -# -# Ansible Galaxy is free software: you can redistribute it and/or modify -# it under the terms of the Apache License as published by -# the Apache Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# Ansible Galaxy is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# Apache License for more details. -# -# You should have received a copy of the Apache License -# along with Galaxy. If not, see . - -import logging -import sys - -from django.conf import settings - -from rest_framework.request import Request - - -__all__ = [ - 'send', -] - -logger = logging.getLogger(__name__) - - -def send(func_name): - def decorator(function): - def wrapper(*args, **kwargs): - # call the view - result = function(*args, **kwargs) - - if settings.METRICS_ENABLED: - # TODO do this async - _send(func_name, args[1]) - - return result - return wrapper - return decorator - - -def _send(func_name, request): - if not isinstance(request, Request): - raise AssertionError( - 'Could not send metrics. ' - 'Expected rest_framework.request.Request, got %s!' - % type(request) - ) - - func = getattr(sys.modules[__name__], func_name, None) - if not callable(func): - raise AssertionError( - 'Could not send metrics. % is not callable!' % func_name - ) - - try: - # FIXME POST? - func(request.GET) - except IOError as e: - logger.exception(e) - - -def search(data): - platforms = data.get('platforms', '').split() - cloud_platforms = data.get('cloud_platforms', '').split() - tags = data.get('tags', '').split() - keywords = data.get('keywords', '').split() - - if not any((platforms, cloud_platforms, tags, keywords)): - return - - search_criteria = { - 'keyword': keywords, - 'platform': platforms, - 'cloud_platform': cloud_platforms, - 'tag': tags, - } - - settings.PROM_CNTR_SEARCH.labels( - keywords=','.join(keywords), - platforms=','.join(platforms), - cloud_platforms=','.join(cloud_platforms), - tags=','.join(tags) - ).inc() - - for criteria_type, criteria_values in search_criteria.items(): - for criteria_value in criteria_values: - settings.PROM_CNTR_SEARCH_CRITERIA.labels( - ctype=criteria_type, cvalue=criteria_value).inc() diff --git a/galaxy/settings/default.py b/galaxy/settings/default.py index 6c9b441a4..82cc4c8dc 100644 --- a/galaxy/settings/default.py +++ b/galaxy/settings/default.py @@ -19,8 +19,6 @@ import os import djcelery -import prometheus_client - djcelery.setup_loader() @@ -297,26 +295,6 @@ If set to `None`, system temporary directory is used. """ -# ========================================================= -# Metrics Settings -# ========================================================= - -METRICS_ENABLED = False - -PROM_CNTR_SEARCH = prometheus_client.Counter( - 'galaxy_search', - '', - ['keywords', 'platforms', 'cloud_platforms', 'tags'], - registry=prometheus_client.REGISTRY -) - -PROM_CNTR_SEARCH_CRITERIA = prometheus_client.Counter( - 'galaxy_search_criteria', - '', - ['ctype', 'cvalue'], - registry=prometheus_client.REGISTRY -) - # ========================================================= # Logging # ========================================================= @@ -440,6 +418,8 @@ # more data will potentially be lost when galaxy restarts. INFLUX_INSERT_BUFFER_COUNT = 5 +GALAXY_METRICS_ENABLED = True + # ========================================================= # Domain Settings diff --git a/galaxy/settings/development.py b/galaxy/settings/development.py index 1b6bc4dad..ddd6c8d4c 100644 --- a/galaxy/settings/development.py +++ b/galaxy/settings/development.py @@ -92,9 +92,3 @@ ] STATIC_ROOT = '' - -# ========================================================= -# Metrics Settings -# ========================================================= - -METRICS_ENABLED = True diff --git a/galaxy/settings/production.py b/galaxy/settings/production.py index 3752ca4ac..716c1b5ad 100644 --- a/galaxy/settings/production.py +++ b/galaxy/settings/production.py @@ -209,13 +209,6 @@ def _set_logging(): LOGGING = _set_logging() -# ========================================================= -# Metrics Settings -# ========================================================= - -METRICS_ENABLED = True - - # ========================================================= # InfluxDB Settings # =========================================================