Revert "Add support for monasca-ui metrics API proxy"

This change breaks the devstack installation. The Monasca datasource
cannot connect with Monasca API. I'm reverting until fixed.

t=2017-12-21T15:27:04+0000 lvl=info msg="Proxying call to [http://192.168.10.6:8070/v2.0/metrics/names]"
t=2017-12-21T15:27:04+0000 lvl=info msg="Request Completed" logger=context userId=2 orgId=2 uname=mini-mon method=GET path=/v2.0/metrics/names status=401 remote_addr=192.168.10.1 time_ms=3ns size=114

This reverts commit bb5178406c.

Change-Id: Ie544c50fa817dbce0865c8885b33312be6d37ccf
This commit is contained in:
Witold Bedyk 2017-12-21 15:29:48 +00:00
parent bb5178406c
commit 5eba5cf392
3 changed files with 13 additions and 107 deletions

View File

@ -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`.

View File

@ -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];

View File

@ -33,27 +33,22 @@
</div>
<div class="gf-form-group">
<h3 class="page-heading">Authentication</h3>
<h3 class="page-heading">Monasca details</h3>
<div class="gf-form-inline">
<div class="gf-form max-width-30" ng-show='ctrl.current.jsonData.authMode == "Token"'>
<div class="gf-form max-width-30">
<span class="gf-form-label width-7">Token</span>
<input class="gf-form-input" type="text" ng-model='ctrl.current.jsonData.token' placeholder=""></input>
<info-popover mode="right-absolute">
<span>A token is required to autenticate if neither Keystone auth nor Horizon auth is set.</span>
<span>A token is required to autenticate if Keystone auth is not set.</span>
</info-popover>
</div>
</div>
<div class="gf-form-inline">
<div class="gf-form max-width-30">
<span class="gf-form-label width-7">Auth</span>
<div class="gf-form-select-wrapper gf-form-select-wrapper--has-help-icon max-width-24">
<select class="gf-form-input" ng-model="ctrl.current.jsonData.authMode" ng-options="f for f in ['Keystone', 'Horizon', 'Token']"></select>
<info-popover mode="right-absolute">
Keystone = Authenticate against Keystone (requires Keystone support in Grafana)<br>
Horizon = Use Horizon session for authentication (requires direct access and monasca-ui Horizon plugin)<br>
Token = Use static Keystone token for authentication
</info-popover>
</div>
<gf-form-switch class="gf-form" label="Keystone Auth"
checked="ctrl.current.jsonData.keystoneAuth" switch-class="max-width-6">
</gf-form-switch>
</div>
</div>
</div>