Updates for grafana 2.
Grafana 2 is only used when GRAFANA_URL is set, otherwise the old proxy method is used. Change-Id: I5e9523b81b30403a6e844f46cd80f483407cb517
This commit is contained in:
parent
ed807abd44
commit
3cb1ff23de
57
ChangeLog
57
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
|
||||
|
20
README.md
20
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 <apache_document_root>/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
|
||||
|
||||
|
98
grafana-dashboards/drilldown.js
Normal file
98
grafana-dashboards/drilldown.js
Normal file
@ -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;
|
@ -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
|
||||
|
||||
|
@ -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/')
|
||||
|
@ -8,12 +8,22 @@
|
||||
{% load url from future %}
|
||||
{% block main %}
|
||||
<div style="padding: 3px;">
|
||||
{% if grafana_url %}
|
||||
<a target="Grafana Home" href="{{grafana_url}}" class="btn btn-default btn-sm">
|
||||
<span class="glyphicon glyphicon-dashboard"></span>
|
||||
Grafana Home
|
||||
</a>
|
||||
{% for dashboard in dashboards %}
|
||||
<a target={{ dashboard.title }} href="/grafana/index.html#/dashboard/file/{{ dashboard.fileName }}?api={{api}}" class="btn btn-default btn-sm">
|
||||
<a target={{ dashboard.title }} href="{{grafana_url}}/dashboard/db/{{ dashboard.path }}" class="btn btn-default btn-sm">
|
||||
<span class="glyphicon glyphicon-dashboard"></span>
|
||||
{% trans dashboard.title %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for dashboard in dashboards %}
|
||||
<a target={{ dashboard.title }} href="/grafana/index.html#/dashboard/file/{{ dashboard.fileName }}?api={{api}}" class="btn btn-default btn-sm">
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if can_access_logs and enable_kibana_button %}
|
||||
<a target="dashboard" href="{% url 'horizon:monitoring:overview:kibana_proxy' url='/' %}" class="btn btn-default btn-sm">
|
||||
<span class="glyphicon glyphicon-dashboard"></span>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user