diff --git a/ChangeLog b/ChangeLog index d2d7b3c4..adac5a75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,63 @@ CHANGES ======= +* Updates for grafana 2 +* Dump thresholds as JSON, not python repr() +* Fix pagination of alarm_definitions and alarms + +1.0.30 +------ + +* Imported Translations from Zanata + +1.0.29 +------ + +* Fix functions of translation +* Remove unused field, add translation target and some adjustments +* Imported Translations from Zanata +* Display all alarms without service +* Imported Translations from Zanata +* KibanaProxyView does not forward headers +* Change Git URL from GitHub to OpenStack + +1.0.28 +------ + +* This is a preparation for using Zanata +* Make timezone memorized when press next(prev) button in alarm history +* Fix the label +* Enhance changing page button of list in monasca-ui +* Fix edit notification page field is too small +* Add help tooltips to creating dialogues +* Add rouded borders to the dimension field +* Drop MANIFEST.in - it's not needed with PBR +* Enhance changing page button of list in monasca-ui +* remove python 2.6 trove classifier +* FIX Overview page to be able to handle multibyte characters +* Move Grafana to Apache's DocumentRoot +* Sync Django with Horizon requirement +* Fix letter case of some words +* FIX the page title +* FIX the description for Notification +* FIX the alarm filter dialog for i18n +* Deprecated tox -downloadcache option removed +* Adding support for ng strict checks +* Delete python bytecode before every test run +* Change link from stackforge to openstack +* Make alarm groups configurable on overview page +* Make match_by item configurable in create alarm definition dialog +* UTC/Browser time as timestamp display format +* Make notification more readable - leftover +* Notification more readable in create alarm dialog +* Change repositories from stackforge to openstack +* Update .gitreview for new namespace +* Allow to specify different static url in js +* Scope requests to horizon scoped region +* Read STATIC_URL from Horizon settings +* UTC/Browser time as timestamp display format +* Fix sorting timestamp column in alarm history table +* The "Create Alarm Definition" dialog is closed unintentionally * Simple Kibana integration * Allow per-project grafana dashboards * Fix unittests diff --git a/README.md b/README.md index 7622667c..0529c058 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ by monasca-vagrant. #Deployment Set Up * git clone https://git.openstack.org/openstack/horizon.git # clone horizon -* git clone https://github.com/hpcloud-mon/grafana.git -* ln -r -s grafana/src *apache_document_root*/grafana * cd horizon * Add git+https://git.openstack.org/openstack/monasca-ui.git to requirements.txt @@ -24,7 +22,8 @@ by monasca-vagrant. ``` git clone https://git.openstack.org/openstack/monasca-ui.git # clone monasca-ui git clone https://git.openstack.org/openstack/horizon.git # clone horizon -git clone https://github.com/hpcloud-mon/grafana.git # clone grafana +git clone https://github.com/twc-openstack/grafana.git # clone grafana +git clone https://github.com/twc-openstack/grafana-plugins.git # clone grafana plugins ``` ##Set up Horizon @@ -52,14 +51,15 @@ ln -s ../monasca-ui/monitoring monitoring ./run_tests #load monasca-client into virtualenv ``` -##Set up Grafana +##Set up Grafana 2.6 -``` -cd .. -ln -r -s grafana/src /grafana -cd grafana -cp config.monasca.js config.js -``` +* The v2.6.0-keystone branch of grafana is stable, as is v2.6.0 in grafana-plugins +* Copy grafana-plugins/datasources/monasca into the grafana/public/app/plugins/datasource/ +* Use the grafana docs to build and deploy grafana +* http://docs.grafana.org/project/building_from_source/ +* http://docs.grafana.org/installation/configuration/ +* Copy monasca-ui/grafana-dashboards/* to /public/dashboards/ in your grafana deployment. +* Set GRAFANA_URL in the horizon settings ##Start Server diff --git a/grafana-dashboards/drilldown.js b/grafana-dashboards/drilldown.js new file mode 100644 index 00000000..d1477952 --- /dev/null +++ b/grafana-dashboards/drilldown.js @@ -0,0 +1,98 @@ +/* global _ */ + +/* + * Complex scripted dashboard + * This script generates a dashboard object that Grafana can load. It also takes a number of user + * supplied URL parameters (in the ARGS variable) + * + * Return a dashboard object, or a function + */ + +'use strict'; + +// accessible variables in this scope +var window, document, ARGS, $, jQuery, moment, kbn; + +// Setup some variables +var dashboard; + +// All url parameters are available via the ARGS object +var ARGS; + +// Intialize a skeleton with nothing but a rows array and service object +dashboard = { + rows : [], +}; + +// Set a title +dashboard.title = 'Alarm drilldown'; + +// Set default time +// time can be overriden in the url using from/to parameters, but this is +// handled automatically in grafana core during dashboard initialization +dashboard.time = { + from: "now-6h", + to: "now" +}; + +var rows = 1; +var metricName = ''; +var hostname = ''; +var region = ''; + +if(!_.isUndefined(ARGS.rows)) { + rows = parseInt(ARGS.rows, 10); +} + +if(!_.isUndefined(ARGS.metric)) { + metricName = ARGS.metric; +} + +if(!_.isUndefined(ARGS.hostname)) { + hostname = ARGS.hostname; +} + +if(!_.isUndefined(ARGS.region)) { + region = ARGS.region; +} + +for (var i = 0; i < rows; i++) { + + dashboard.rows.push({ + title: 'Chart', + height: '300px', + panels: [ + { + title: metricName, + type: 'graph', + span: 12, + fill: 1, + linewidth: 2, + targets: [ + { + "aggregator": "avg", + "alias": hostname, + "dimensions": [ + { + "key": "hostname", + "value": hostname + }, + { + "key": "region", + "value": region + } + ], + "metric": metricName, + "period": "300", + } + ], + tooltip: { + shared: true + } + } + ] + }); +} + + +return dashboard; diff --git a/monitoring/alarms/tables.py b/monitoring/alarms/tables.py index 21c700db..a5dc0128 100644 --- a/monitoring/alarms/tables.py +++ b/monitoring/alarms/tables.py @@ -158,14 +158,28 @@ class GraphMetric(tables.LinkAction): return super(self, GraphMetric).render() def get_link_url(self, datum): - name = datum['metrics'][0]['name'] - threshold = json.dumps(datum['metrics']) - endpoint = str(reverse_lazy(ov_constants.URL_PREFIX + 'proxy')) - endpoint = self.table.request.build_absolute_uri(endpoint) + url = '' + query = '' self.attrs['target'] = '_blank' - url = (settings.STATIC_URL or '') + \ - 'grafana/index.html#/dashboard/script/detail.js' - query = "?name=%s&threshold=%s&api=%s" % \ + try: + region = self.table.request.user.services_region + grafana_url = getattr(settings, 'GRAFANA_URL').get(region, '') + url = grafana_url + \ + '/dashboard/script/drilldown.js' + metric = datum['metrics'][0]['name'] + dimensions = datum['metrics'][0].get('dimensions', {}) + query = "?metric=%s" % metric + for key, value in dimensions.iteritems(): + query += "&%s=%s" % (key, value) + except AttributeError: + # Catches case where Grafana 2 is not enabled. + name = datum['metrics'][0]['name'] + threshold = json.dumps(datum['metrics']) + endpoint = str(reverse_lazy(ov_constants.URL_PREFIX + 'proxy')) + endpoint = self.table.request.build_absolute_uri(endpoint) + url = (settings.STATIC_URL or '') + \ + 'grafana/index.html#/dashboard/script/detail.js' + query = "?name=%s&threshold=%s&api=%s" % \ (name, threshold, endpoint) return url + query diff --git a/monitoring/config/local_settings.py b/monitoring/config/local_settings.py index c5c4a1eb..2b59eedc 100644 --- a/monitoring/config/local_settings.py +++ b/monitoring/config/local_settings.py @@ -34,29 +34,25 @@ MONITORING_SERVICE_TYPE = getattr( ) # Grafana button titles/file names (global across all projects): -GRAFANA_LINKS = [ - {'title': _('Dashboard'), 'fileName': 'openstack.json'}, - {'title': _('Monasca Health'), 'fileName': 'monasca.json'} -] - -DEFAULT_LINKS = GRAFANA_LINKS +GRAFANA_LINKS = [] DASHBOARDS = getattr(settings, 'GRAFANA_LINKS', GRAFANA_LINKS) # -# Per project grafana button titles/file names. If in this form, -# '*' will be applied to all projects not explicitly listed. +# Horizon will link to the grafana home page when using Grafana2. +# For any Grafana version additional links to specific dashboards can be +# created in two formats. +# Flat: +# GRAFANA_LINKS = [ {'title': _('Dashboard'), 'path': 'openstack'} ] # -# Note the above form (flat) is supported for backward compatibility. -# -#GRAFANA_LINKS = [ +# Per project: '*' will be applied to all projects not explicitly listed. +# GRAFANA_LINKS = [ # {'admin': [ -# {'title': _('Dashboard'), 'fileName': 'openstack.json'}, -# {'title': _('RabbitMQ'), 'fileName': 'rabbit.json'}, -# {'title': _('Project Utilization'), 'fileName': 'libvirt.json'}]}, +# {'title': _('Dashboard'), 'path': 'openstack'}]}, # {'*': [ -# {'title': _('OpenStack Dashboard'), 'fileName': 'project.json'}, -# {'title': _('Add New Dashboard'), 'fileName': 'empty.json'}]} -#] +# {'title': _('OpenStack Dashboard'), 'path': 'project'}]} +# ] + +GRAFANA_URL = getattr(settings, 'GRAFANA_URL', None) ENABLE_KIBANA_BUTTON = getattr(settings, 'ENABLE_KIBANA_BUTTON', False) KIBANA_HOST = getattr(settings, 'KIBANA_HOST', 'http://192.168.10.4:5601/') diff --git a/monitoring/overview/templates/overview/index.html b/monitoring/overview/templates/overview/index.html index 2396630f..f3277cc6 100644 --- a/monitoring/overview/templates/overview/index.html +++ b/monitoring/overview/templates/overview/index.html @@ -8,12 +8,22 @@ {% load url from future %} {% block main %}
+ {% if grafana_url %} + + + Grafana Home + {% for dashboard in dashboards %} - + {% trans dashboard.title %} {% endfor %} + {% else %} + {% for dashboard in dashboards %} + + {% endfor %} + {% endif %} {% if can_access_logs and enable_kibana_button %} diff --git a/monitoring/overview/views.py b/monitoring/overview/views.py index 7d5110bc..e8541ee2 100644 --- a/monitoring/overview/views.py +++ b/monitoring/overview/views.py @@ -223,9 +223,14 @@ class IndexView(TemplateView): def get_context_data(self, **kwargs): context = super(IndexView, self).get_context_data(**kwargs) - proxy_url_path = str(reverse_lazy(constants.URL_PREFIX + 'proxy')) - api_root = self.request.build_absolute_uri(proxy_url_path) - context["api"] = api_root + try: + region = self.request.user.services_region + context["grafana_url"] = getattr(settings, 'GRAFANA_URL').get(region, '') + except AttributeError: + # Catches case where Grafana 2 is not enabled. + proxy_url_path = str(reverse_lazy(constants.URL_PREFIX + 'proxy')) + api_root = self.request.build_absolute_uri(proxy_url_path) + context["api"] = api_root context["dashboards"] = get_dashboard_links(self.request) context['can_access_logs'] = policy.check( (('identity', 'admin_required'), ), self.request