Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
.generic-datasource-query-row .query-keyword {
|
||||
width: 75px;
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
// ################################################################################
|
||||
// # Copyright (c) 2018 JamesOsgood
|
||||
// #
|
||||
// # Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// # of this software and associated documentation files (the "Software"), to deal
|
||||
// # in the Software without restriction, including without limitation the rights
|
||||
// # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// # copies of the Software, and to permit persons to whom the Software is
|
||||
// # furnished to do so, subject to the following conditions:
|
||||
// #
|
||||
// # The above copyright notice and this permission notice shall be included in all
|
||||
// # copies or substantial portions of the Software.
|
||||
// #
|
||||
// # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// # SOFTWARE.
|
||||
// ################################################################################
|
||||
|
||||
import _ from "lodash";
|
||||
|
||||
export class GenericDatasource {
|
||||
|
||||
constructor(instanceSettings, $q, backendSrv, templateSrv) {
|
||||
this.type = instanceSettings.type;
|
||||
this.url = instanceSettings.url;
|
||||
this.name = instanceSettings.name;
|
||||
this.db = { 'url' : instanceSettings.jsonData.mongodb_url, 'db' : instanceSettings.jsonData.mongodb_db }
|
||||
this.q = $q;
|
||||
this.backendSrv = backendSrv;
|
||||
this.templateSrv = templateSrv;
|
||||
this.withCredentials = instanceSettings.withCredentials;
|
||||
this.headers = {'Content-Type': 'application/json'};
|
||||
// Assert valid sign in parameter
|
||||
if (typeof instanceSettings.basicAuth === 'string' && instanceSettings.basicAuth.length > 0) {
|
||||
this.headers['Authorization'] = instanceSettings.basicAuth;
|
||||
}
|
||||
}
|
||||
|
||||
query(options) {
|
||||
var query = this.buildQueryParameters(options);
|
||||
query.targets = query.targets.filter(t => !t.hide);
|
||||
query.db = this.db
|
||||
|
||||
if (query.targets.length <= 0) {
|
||||
return this.q.when({data: []});
|
||||
}
|
||||
|
||||
return this.doRequest({
|
||||
url: this.url + '/query',
|
||||
data: query,
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
|
||||
// Testing whether connection is valid
|
||||
testDatasource() {
|
||||
return this.doRequest({
|
||||
url: this.url + '/',
|
||||
data : { db : this.db },
|
||||
method: 'POST',
|
||||
}).then(response => {
|
||||
if (response.status === 200) {
|
||||
return { status: response.data.status, message: response.data.message, title: response.data.display_status };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
annotationQuery(options) {
|
||||
var query = this.templateSrv.replace(options.annotation.query, {}, 'glob');
|
||||
var annotationQuery = {
|
||||
range: options.range,
|
||||
annotation: {
|
||||
name: options.annotation.name,
|
||||
datasource: options.annotation.datasource,
|
||||
enable: options.annotation.enable,
|
||||
iconColor: options.annotation.iconColor,
|
||||
query: query
|
||||
},
|
||||
rangeRaw: options.rangeRaw
|
||||
};
|
||||
|
||||
return this.doRequest({
|
||||
url: this.url + '/annotations',
|
||||
method: 'POST',
|
||||
data: annotationQuery
|
||||
}).then(result => {
|
||||
response.data.$$status = result.status;
|
||||
response.data.$$config = result.config;
|
||||
return result.data;
|
||||
});
|
||||
}
|
||||
|
||||
metricFindQuery(query) {
|
||||
var interpolated = {
|
||||
target: this.templateSrv.replace(query, null, '')
|
||||
};
|
||||
interpolated.db = this.db
|
||||
|
||||
return this.doRequest({
|
||||
url: this.url + '/search',
|
||||
data: interpolated,
|
||||
method: 'POST',
|
||||
}).then(this.mapToTextValue);
|
||||
}
|
||||
|
||||
mapToTextValue(result) {
|
||||
return _.map(result.data, (d, i) => {
|
||||
if (d && d.text && d.value) {
|
||||
return { text: d.text, value: d.value };
|
||||
} else if (_.isObject(d)) {
|
||||
return { text: d, value: i};
|
||||
}
|
||||
return { text: d, value: d };
|
||||
});
|
||||
}
|
||||
|
||||
doRequest(options) {
|
||||
options.withCredentials = this.withCredentials;
|
||||
options.headers = this.headers;
|
||||
|
||||
return this.backendSrv.datasourceRequest(options);
|
||||
}
|
||||
|
||||
buildQueryParameters(options) {
|
||||
//remove place holder targets
|
||||
options.targets = _.filter(options.targets, target => {
|
||||
return target.target !== 'select metric';
|
||||
});
|
||||
|
||||
var targets = _.map(options.targets, target => {
|
||||
return {
|
||||
target: this.templateSrv.replace(target.target, options.scopedVars, ''),
|
||||
refId: target.refId,
|
||||
hide: target.hide,
|
||||
type: target.type || 'timeserie'
|
||||
};
|
||||
});
|
||||
|
||||
options.targets = targets;
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<!-- ################################################################################
|
||||
# Copyright (c) 2018 JamesOsgood
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
################################################################################ -->
|
||||
|
||||
<h5 class="section-heading">Query</h5>
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form">
|
||||
<input type="text" class="gf-form-input" ng-model='ctrl.annotation.query' placeholder=""></input>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,48 @@
|
||||
<!-- ################################################################################
|
||||
# Copyright (c) 2018 JamesOsgood
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
################################################################################ -->
|
||||
|
||||
<datasource-http-settings current="ctrl.current">
|
||||
</datasource-http-settings>
|
||||
|
||||
<h3 class="page-heading">MongoDB details</h3>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">MongoDB URL</span>
|
||||
<input class="gf-form-input width-30" type="text"
|
||||
ng-model='ctrl.current.jsonData.mongodb_url'
|
||||
placeholder="mongodb://localhost:27017" required>
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<!--TODO: Make this compatible with $db Grafana variable-->
|
||||
<span class="gf-form-label width-10">Database Name</span>
|
||||
<input class="gf-form-input width-30" type="text"
|
||||
ng-model='ctrl.current.jsonData.mongodb_db'
|
||||
placeholder="myDatabase" required>
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<!-- ################################################################################
|
||||
# Copyright (c) 2018 JamesOsgood
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
################################################################################ -->
|
||||
|
||||
<query-editor-row query-ctrl="ctrl" class="generic-datasource-query-row" has-text-edit-mode="true">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-8">
|
||||
<!--Drop down menu for selecting query type-->
|
||||
<select class="gf-form-input" ng-model="ctrl.target.type" ng-options="f as f for f in ['table', 'timeseries']"></select>
|
||||
</div>
|
||||
|
||||
<div class="gf-form" ng-if="ctrl.target.rawQuery">
|
||||
<textarea class="gf-form-input" rows="5" cols="150" ng-model="ctrl.target.target" spellcheck="false" ng-blur="ctrl.onChangeInternal()" />
|
||||
</div>
|
||||
|
||||
<div ng-if="!ctrl.target.rawQuery">
|
||||
<div class="gf-form">
|
||||
<gf-form-dropdown model="ctrl.target.target"
|
||||
allow-custom="true"
|
||||
lookup-text="true"
|
||||
get-options="ctrl.getOptions($query)"
|
||||
on-change="ctrl.onChangeInternal()">
|
||||
</gf-form-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--auto">
|
||||
<div class="gf-form-label gf-form-label--auto"></div>
|
||||
</div>
|
||||
</div>
|
||||
</query-editor-row>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<!-- ################################################################################
|
||||
# Copyright (c) 2018 JamesOsgood
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
################################################################################ -->
|
||||
|
||||
<section class="grafana-metric-options" >
|
||||
<div class="gf-form">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Binary file not shown.
|
Efter Bredd: | Höjd: | Storlek: 67 KiB |
Binary file not shown.
|
Efter Bredd: | Höjd: | Storlek: 47 KiB |
@@ -0,0 +1,41 @@
|
||||
// ################################################################################
|
||||
// # Copyright (c) 2018 JamesOsgood
|
||||
// #
|
||||
// # Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// # of this software and associated documentation files (the "Software"), to deal
|
||||
// # in the Software without restriction, including without limitation the rights
|
||||
// # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// # copies of the Software, and to permit persons to whom the Software is
|
||||
// # furnished to do so, subject to the following conditions:
|
||||
// #
|
||||
// # The above copyright notice and this permission notice shall be included in all
|
||||
// # copies or substantial portions of the Software.
|
||||
// #
|
||||
// # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// # SOFTWARE.
|
||||
// ################################################################################
|
||||
|
||||
import {GenericDatasource} from './datasource';
|
||||
import {GenericDatasourceQueryCtrl} from './query_ctrl';
|
||||
|
||||
class GenericConfigCtrl {}
|
||||
GenericConfigCtrl.templateUrl = 'html/config.html';
|
||||
|
||||
class GenericQueryOptionsCtrl {}
|
||||
GenericQueryOptionsCtrl.templateUrl = 'html/query.options.html';
|
||||
|
||||
class GenericAnnotationsQueryCtrl {}
|
||||
GenericAnnotationsQueryCtrl.templateUrl = 'html/annotations.editor.html'
|
||||
|
||||
export {
|
||||
GenericDatasource as Datasource,
|
||||
GenericDatasourceQueryCtrl as QueryCtrl,
|
||||
GenericConfigCtrl as ConfigCtrl,
|
||||
GenericQueryOptionsCtrl as QueryOptionsCtrl,
|
||||
GenericAnnotationsQueryCtrl as AnnotationsQueryCtrl
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "Omniperf Data",
|
||||
"id": "amd-omniperf-data-plugin",
|
||||
"type": "datasource",
|
||||
"backend": true,
|
||||
"partials": {
|
||||
"config": "public/app/plugins/datasource/simplejson/partials/config.html"
|
||||
},
|
||||
"metrics": true,
|
||||
"annotations": false,
|
||||
"info": {
|
||||
"description": "An Omniperf datasource build for MongoDB",
|
||||
"author": {
|
||||
"name": "Audacious Software Group",
|
||||
"url": ""
|
||||
},
|
||||
"logos": {
|
||||
"small": "img/omniperf_circle.png",
|
||||
"large": "img/omniperf_circle.png"
|
||||
},
|
||||
"version": "%VERSION%",
|
||||
"updated": "%TODAY%"
|
||||
},
|
||||
"dependencies": {
|
||||
"grafanaVersion": ">=7.0.0",
|
||||
"plugins": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// ################################################################################
|
||||
// # Copyright (c) 2018 JamesOsgood
|
||||
// #
|
||||
// # Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// # of this software and associated documentation files (the "Software"), to deal
|
||||
// # in the Software without restriction, including without limitation the rights
|
||||
// # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// # copies of the Software, and to permit persons to whom the Software is
|
||||
// # furnished to do so, subject to the following conditions:
|
||||
// #
|
||||
// # The above copyright notice and this permission notice shall be included in all
|
||||
// # copies or substantial portions of the Software.
|
||||
// #
|
||||
// # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// # SOFTWARE.
|
||||
// ################################################################################
|
||||
|
||||
import {QueryCtrl} from 'app/plugins/sdk';
|
||||
import './css/query-editor.css!'
|
||||
|
||||
export class GenericDatasourceQueryCtrl extends QueryCtrl {
|
||||
|
||||
constructor($scope, $injector) {
|
||||
super($scope, $injector);
|
||||
|
||||
this.scope = $scope;
|
||||
this.target.target = this.target.target || 'select metric';
|
||||
this.target.type = this.target.type || 'timeserie';
|
||||
this.target.rawQuery = true;
|
||||
}
|
||||
|
||||
getOptions(query) {
|
||||
return this.datasource.metricFindQuery(query || '');
|
||||
}
|
||||
|
||||
toggleEditorMode() {
|
||||
this.target.rawQuery = !this.target.rawQuery;
|
||||
}
|
||||
|
||||
onChangeInternal() {
|
||||
this.panelCtrl.refresh(); // Asks the panel to refresh data.
|
||||
}
|
||||
}
|
||||
|
||||
GenericDatasourceQueryCtrl.templateUrl = 'html/query.editor.html';
|
||||
|
||||
Referens i nytt ärende
Block a user