diff --git a/monitoring/config/local_settings.py b/monitoring/config/local_settings.py index 9e50b5bd..ea1b919f 100644 --- a/monitoring/config/local_settings.py +++ b/monitoring/config/local_settings.py @@ -61,18 +61,49 @@ DASHBOARDS = getattr(settings, 'GRAFANA_LINKS', GRAFANA_LINKS) # For any Grafana version additional links to specific dashboards can be # created in two formats. # Flat: -# GRAFANA_LINKS = [ {'title': _('Dashboard'), 'path': 'openstack'} ] +# GRAFANA_LINKS = [ {'title': _('Dashboard'), 'path': 'openstack', 'raw': False} ] # # Per project: '*' will be applied to all projects not explicitly listed. # GRAFANA_LINKS = [ # {'admin': [ -# {'title': _('Dashboard'), 'path': 'openstack'}]}, +# {'title': _('Dashboard'), 'path': 'openstack', 'raw': False}]}, # {'*': [ -# {'title': _('OpenStack Dashboard'), 'path': 'project'}]} +# {'title': _('OpenStack Dashboard'), 'path': 'project', 'raw': False}]} # ] +# +# If GRAFANA_URL is specified, the dashboard file name/raw URL must be +# specified through the 'path' attribute as shown above. +# +# Flat: +# GRAFANA_LINKS = [ {'title': _('Dashboard'), 'fileName': 'openstack.json', 'raw': False} ] +# +# GRAFANA_LINKS = [ +# {'admin': [ +# {'fileName': _('Dashboard'), 'fileName': 'openstack.json', 'raw': False}]}, +# {'*': [ +# {'title': _('OpenStack Dashboard'), 'fileName': 'project.json': False}]} +# ] +# +# If GRAFANA_URL is unspecified the dashboard file name must be specified +# through the fileName attribute. +# +# Both with and without GRAFANA_URL, the links have an optional 'raw' attribute +# which defaults to False if unspecified. If it is False, the value of 'path' +# (or 'fileName', respectively) is interpreted as a dashboard name and a link +# to the dashboard based on the dashboard's name will be generated. If it is +# True, the value of 'path' or 'fileName' will be treated as a URL to be used +# verbatim. + + GRAFANA_URL = getattr(settings, 'GRAFANA_URL', None) +# If GRAFANA_URL is specified, an additional link will be shown that points to +# Grafana's list of dashboards. If you do not wish this, set SHOW_GRAFANA_HOME +# to False (by default this setting is True and the link will thus be shown). + +SHOW_GRAFANA_HOME = getattr(settings, 'SHOW_GRAFANA_HOME', True) + ENABLE_KIBANA_BUTTON = getattr(settings, 'ENABLE_KIBANA_BUTTON', False) KIBANA_POLICY_RULE = getattr(settings, 'KIBANA_POLICY_RULE', 'monitoring:kibana_access') diff --git a/monitoring/overview/templates/overview/index.html b/monitoring/overview/templates/overview/index.html index 2e16bfff..cfc33957 100644 --- a/monitoring/overview/templates/overview/index.html +++ b/monitoring/overview/templates/overview/index.html @@ -8,19 +8,29 @@ {% block main %}
{% if grafana_url %} + {% if show_grafana_home %} Grafana Home + {% endif %} {% for dashboard in dashboards %} + {% if dashboard.raw %} + + {% else %} + {% endif %} {% trans dashboard.title %} {% endfor %} {% else %} {% for dashboard in dashboards %} + {% if dashboard.raw %} + + {% else %} + {% endif %} {% trans dashboard.title %} diff --git a/monitoring/overview/views.py b/monitoring/overview/views.py index 86f6b45d..f2c3fc52 100644 --- a/monitoring/overview/views.py +++ b/monitoring/overview/views.py @@ -240,10 +240,14 @@ class IndexView(TemplateView): api_root = self.request.build_absolute_uri(proxy_url_path) context["api"] = api_root context["dashboards"] = get_dashboard_links(self.request) + # Ensure all links have a 'raw' attribute + for link in context["dashboards"]: + link['raw'] = link.get('raw', False) context['can_access_logs'] = policy.check( ((getattr(settings, 'KIBANA_POLICY_SCOPE'), getattr(settings, 'KIBANA_POLICY_RULE')), ), self.request ) context['enable_kibana_button'] = settings.ENABLE_KIBANA_BUTTON + context['show_grafana_home'] = settings.SHOW_GRAFANA_HOME return context @@ -261,7 +265,9 @@ class MonascaProxyView(TemplateView): dimensions_str = req_kwargs['dimensions'][0] dimensions_str_array = dimensions_str.split(',') for dimension in dimensions_str_array: - dimension_name_value = dimension.split(':') + # limit splitting since value may contain a ':' such as in + # the `url` dimension of the service_status check. + dimension_name_value = dimension.split(':', 1) if len(dimension_name_value) == 2: name = dimension_name_value[0].encode('utf8') value = dimension_name_value[1].encode('utf8')