diff --git a/README.md b/README.md index 504a20f..df43060 100644 --- a/README.md +++ b/README.md @@ -9,70 +9,6 @@ Team and repository tags For more information on Monasca see the [Monasca documentation](https://wiki.openstack.org/wiki/Monasca) -## Authentication Options - -### Horizon Session - -The [Monasca Horizon plugin](https://github.com/openstack/monasca-ui) offers -Horizon integration for Monasca. Among other things this plugin proxies the -Monasca metrics API, using the Horizon session for authentication (as opposed -to a Keystone token). This proxied API can be used to let this plugin access -the Monasca API with the privileges of the user logged in to Horizon. - -Note that this is entirely separate from Grafana's user management. - -Setting this up requires the following steps: - -1. Install and configure the `monasca-ui` Horizon plugin. Specifically you will - need to set `GRAFANA_URL` to `/grafana` and point `GRAFANA_LINKS` to your - dashboards which can either be JSON dashboards you point to or in-database - dashboards. In the former case set the links' `raw` attribute to `True` and - their `path` attribute to the dashboard's path or full URL. In the - latter case, set the links' `raw` attribute to `False` (or omit it entirely) - and set their `path` attributes to the database dashboards' names. - -2. Enable `mod_proxy` and `mod_proxy_http` in Apache: - - ``` - a2enmod proxy proxy_http - ``` - -3. Configure the VHost hosting your Horizon instance with a proxy path that - points at your Grafana instance (the example assumes you are running Horizon - on Apache - adapt as required for other web servers): - - ``` - ProxyPass "/grafana" "http://my.grafana.server:3000" - ProxyPassReverse "/grafana" "http://my.grafana.server:3000" - - ``` - -4. Configure Grafana's `[server/root_url]` setting to point at your dashboard - node's `/grafana` path: - - ``` - [server] - root_url = %(protocol)s://%(domain)s/grafana - ``` - -5. Configure the plugin as follows: - - * Http settings: - * Url: `http://my.dashboard.server/monitoring/proxy` (substitute your - dashboard's actual host name for `my.dashboard.server` here) - * Access: direct - * Authentication - * Auth: Horizon - -Steps (2) and (3) are neccessary to ensure both Grafana and Horizon are on the -same Host/Port from the browser's perspective. Otherwise the browser's XSS -protection mechanisms will omit the Horizon session cookie from any requests -triggered by the `monasca-grafana-datasource` plugin. - -### Keystone Authentication - When combined with Grafana Keystone authentication this datasource supports using login credentials to authenticate queries. -### Keystone Token - Without the Grafana Keystone auth, this datasource can be used by inserting a keystone token into the datasource. To get a keystone token download the python-openstackclient, source credentials and run `openstack token issue`. diff --git a/datasource.js b/datasource.js index 62bd62e..7122541 100644 --- a/datasource.js +++ b/datasource.js @@ -14,34 +14,14 @@ function (angular, _, moment, sdk, dateMath, kbn) { function MonascaDatasource(instanceSettings, $q, backendSrv, templateSrv) { this.url = instanceSettings.url; - this.url_version = '/v2.0' this.name = instanceSettings.name; if (instanceSettings.jsonData) { this.token = instanceSettings.jsonData.token; - switch ( instanceSettings.jsonData.authMode ) { - case "Keystone": - this.keystoneAuth = true; - this.useHorizonProxy = false; - break; - case "Horizon": - this.keystoneAuth = false; - this.useHorizonProxy = true; - this.token = null; - break; - case "Token": - this.keystoneAuth = false; - this.useHorizonProxy = false; - break; - } + this.keystoneAuth = instanceSettings.jsonData.keystoneAuth; } else { this.token = null; this.keystoneAuth = null; - this.useHorizonProxy = false; - } - - if ( this.useHorizonProxy == true ) { - this.url_version = ''; } this.q = $q; @@ -95,36 +75,31 @@ function (angular, _, moment, sdk, dateMath, kbn) { }; MonascaDatasource.prototype.metricsQuery = function(params) { - var url = this.url_version + '/metrics'; - return this._limitedMonascaRequest(url, params, true).catch(function(err) {throw err;}); + return this._limitedMonascaRequest('/v2.0/metrics', params, true).catch(function(err) {throw err;}); }; MonascaDatasource.prototype.namesQuery = function() { var datasource = this; - var url = this.url_version + '/metrics/names'; - return this._limitedMonascaRequest(url, {}, false).then(function(data) { + return this._limitedMonascaRequest('/v2.0/metrics/names', {}, false).then(function(data) { return datasource.convertDataList(data, 'name'); }).catch(function(err) {throw err;}); }; MonascaDatasource.prototype.dimensionNamesQuery = function(params) { var datasource = this; - var url = this.url_version + '/metrics/dimensions/names'; - return this._limitedMonascaRequest(url, params, false).then(function(data) { + return this._limitedMonascaRequest('/v2.0/metrics/dimensions/names', params, false).then(function(data) { return datasource.convertDataList(data, 'dimension_name'); }).catch(function(err) {throw err;}); }; MonascaDatasource.prototype.dimensionValuesQuery = function(params) { var datasource = this; - var url = this.url_version + '/metrics/dimensions/names/values'; - return this._limitedMonascaRequest(url, params, false).then(function(data) { + return this._limitedMonascaRequest('/v2.0/metrics/dimensions/names/values', params, false).then(function(data) { return datasource.convertDataList(data, 'dimension_value'); }).catch(function(err) {throw err;}); }; MonascaDatasource.prototype.convertDataList = function(data, key) { - if ( JSON.stringify(data.data) === '{}' ) { return {}; } var values = data.data.elements.map(function(element) { return element[key]; }); @@ -174,10 +149,10 @@ function (angular, _, moment, sdk, dateMath, kbn) { if (options.aggregator && options.aggregator != 'none') { params.statistics = options.aggregator; params.period = options.period; - path = this.url_version + '/metrics/statistics?'; + path = '/v2.0/metrics/statistics?'; } else { - path = this.url_version + '/metrics/measurements?'; + path = '/v2.0/metrics/measurements?'; } path += Object.keys(params).map(function(key) { return key + '=' + params[key]; diff --git a/partials/config.html b/partials/config.html index e4ec812..be0fd0d 100644 --- a/partials/config.html +++ b/partials/config.html @@ -33,27 +33,22 @@
-

Authentication

+

Monasca details

-
+
Token - A token is required to autenticate if neither Keystone auth nor Horizon auth is set. + A token is required to autenticate if Keystone auth is not set.
Auth -
- - - Keystone = Authenticate against Keystone (requires Keystone support in Grafana)
- Horizon = Use Horizon session for authentication (requires direct access and monasca-ui Horizon plugin)
- Token = Use static Keystone token for authentication -
-
+ +