mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 08:22:20 +08:00
mysql: reading arbitrary SQL data in go is really strange, data is only in strings?
This commit is contained in:
@ -7,24 +7,34 @@ export class MysqlDatasource {
|
||||
name: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(instanceSettings, private backendSrv) {
|
||||
constructor(instanceSettings, private backendSrv, private $q) {
|
||||
this.name = instanceSettings.name;
|
||||
this.id = instanceSettings.id;
|
||||
}
|
||||
|
||||
query(options) {
|
||||
var queries = _.filter(options.targets, item => {
|
||||
return item.hide !== true;
|
||||
}).map(item => {
|
||||
return {
|
||||
refId: item.refId,
|
||||
intervalMs: options.intervalMs,
|
||||
maxDataPoints: options.maxDataPoints,
|
||||
datasourceId: this.id,
|
||||
rawSql: item.rawSql,
|
||||
};
|
||||
});
|
||||
|
||||
if (queries.length === 0) {
|
||||
return this.$q.when({data: []});
|
||||
}
|
||||
|
||||
return this.backendSrv.post('/api/tsdb/query', {
|
||||
from: options.range.from.valueOf().toString(),
|
||||
to: options.range.to.valueOf().toString(),
|
||||
queries: [
|
||||
{
|
||||
"refId": "A",
|
||||
"intervalMs": options.intervalMs,
|
||||
"maxDataPoints": options.maxDataPoints,
|
||||
"datasourceId": this.id,
|
||||
}
|
||||
]
|
||||
queries: queries,
|
||||
}).then(res => {
|
||||
console.log('mysql response', res);
|
||||
|
||||
var data = [];
|
||||
if (res.results) {
|
||||
|
@ -8,7 +8,7 @@ class MysqlQueryCtrl extends QueryCtrl {
|
||||
static templateUrl = 'partials/query.editor.html';
|
||||
}
|
||||
|
||||
class InfluxConfigCtrl {
|
||||
class MysqlConfigCtrl {
|
||||
static templateUrl = 'partials/config.html';
|
||||
}
|
||||
|
||||
@ -16,5 +16,6 @@ export {
|
||||
MysqlDatasource,
|
||||
MysqlDatasource as Datasource,
|
||||
MysqlQueryCtrl as QueryCtrl,
|
||||
MysqlConfigCtrl as ConfigCtrl,
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<query-editor-row query-ctrl="ctrl" can-collapse="false">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label">Test metric (fake data source)</label>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form gf-form--grow">
|
||||
<textarea rows="3" class="gf-form-input" ng-model="ctrl.target.rawSql" spellcheck="false" placeholder="query expression" data-min-length=0 data-items=100 ng-model-onblur ng-change="ctrl.refreshMetricData()"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</query-editor-row>
|
||||
|
@ -3,6 +3,17 @@
|
||||
"name": "MySQL",
|
||||
"id": "mysql",
|
||||
|
||||
"info": {
|
||||
"author": {
|
||||
"name": "Grafana Project",
|
||||
"url": "https://grafana.com"
|
||||
},
|
||||
"logos": {
|
||||
"small": "img/mysql_logo.svg",
|
||||
"large": "img/mysql_logo.svg"
|
||||
}
|
||||
},
|
||||
|
||||
"annotations": true,
|
||||
"metrics": true
|
||||
}
|
||||
|
Reference in New Issue
Block a user