Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL Support #23

Open
nniehoff opened this issue Aug 13, 2021 · 1 comment
Open

MySQL Support #23

nniehoff opened this issue Aug 13, 2021 · 1 comment

Comments

@nniehoff
Copy link
Contributor

Environment

  • Python version: 3.7
  • Nautobot version: 1.1.2
  • nautobot-capacity-metrics version: 1.0.1

Expected Behavior

Capacit metrics works with MySQL Backend

Observed Behavior

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 171, in _get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "/usr/local/lib/python3.6/site-packages/newrelic/hooks/framework_django.py", line 242, in wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/dolt/middleware.py", line 50, in process_view
    return view_func(request, *view_args, **view_kwargs)
  File "/usr/local/lib/python3.6/site-packages/newrelic/hooks/framework_django.py", line 562, in wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nautobot_capacity_metrics/api/views.py", line 88, in AppMetricsView
    return ExportToDjangoView(request, view="app-metrics")
  File "/usr/local/lib/python3.6/site-packages/nautobot_capacity_metrics/api/views.py", line 77, in ExportToDjangoView
    metrics_page = prometheus_client.generate_latest(registry)
  File "/usr/local/lib/python3.6/site-packages/prometheus_client/exposition.py", line 177, in generate_latest
    for metric in registry.collect():
  File "/usr/local/lib/python3.6/site-packages/prometheus_client/registry.py", line 83, in collect
    for metric in collector.collect():
  File "/usr/local/lib/python3.6/site-packages/nautobot_capacity_metrics/api/views.py", line 26, in collect
    for metric in metric_jobs():
  File "/usr/local/lib/python3.6/site-packages/nautobot_capacity_metrics/metrics.py", line 79, in metric_jobs
    for job in job_results:
  File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 287, in __iter__
    self._fetch_all()
  File "/usr/local/lib/python3.6/site-packages/cacheops/query.py", line 273, in _fetch_all
    return self._no_monkey._fetch_all(self)
  File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 1308, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1143, in execute_sql
    sql, params = self.as_sql()
  File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 521, in as_sql
    distinct_params,
  File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/operations.py", line 176, in distinct_sql
    raise NotSupportedError('DISTINCT ON fields is not supported by this database backend')

Steps to Reproduce

  1. Use MySQL
@dgarros
Copy link
Contributor

dgarros commented Nov 2, 2021

Looks like the issue is related specifically to the metric_jobs function
https://github.com/nautobot/nautobot-plugin-capacity-metrics/blob/cca347b62fe240afc6d98a069dfc86ba77acbcd8/nautobot_capacity_metrics/metrics.py#L65

As a workaround, it's recommended to disable both Jobs and gitrepositories in the plugin configuration when using MySQL until a proper fix has been implemented

PLUGINS_CONFIG = {
    "nautobot_capacity_metrics": {
        "app_metrics": {
            "gitrepositories": False,
            "jobs": False,
        }
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants