mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
sql: wip mysql stuff
This commit is contained in:
3
public/app/plugins/datasource/mysql/README.md
Normal file
3
public/app/plugins/datasource/mysql/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Grafana Fake Data Datasource - Native Plugin
|
||||
|
||||
This is the built in Fake Data Datasource that is used before any datasources are set up in your Grafana installation. It means you can create a graph without any data and still get an idea of what it would look like.
|
43
public/app/plugins/datasource/mysql/datasource.ts
Normal file
43
public/app/plugins/datasource/mysql/datasource.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
export class MysqlDatasource {
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private instanceSettings, private backendSrv) {
|
||||
}
|
||||
|
||||
query(options) {
|
||||
console.log('test');
|
||||
console.log(this.instanceSettings);
|
||||
return this.backendSrv.post('/api/tsdb/query', {
|
||||
from: options.range.from.valueOf().toString(),
|
||||
to: options.range.to.valueOf().toString(),
|
||||
queries: [
|
||||
{
|
||||
"refId": "A",
|
||||
"scenarioId": "random_walk",
|
||||
"intervalMs": options.intervalMs,
|
||||
"maxDataPoints": options.maxDataPoints,
|
||||
}
|
||||
]
|
||||
}).then(res => {
|
||||
|
||||
var data = [];
|
||||
if (res.results) {
|
||||
_.forEach(res.results, queryRes => {
|
||||
for (let series of queryRes.series) {
|
||||
data.push({
|
||||
target: series.name,
|
||||
datapoints: series.points
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {data: data};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
16
public/app/plugins/datasource/mysql/module.ts
Normal file
16
public/app/plugins/datasource/mysql/module.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
import angular from 'angular';
|
||||
import {MysqlDatasource} from './datasource';
|
||||
import {QueryCtrl} from 'app/plugins/sdk';
|
||||
|
||||
class MysqlQueryCtrl extends QueryCtrl {
|
||||
static templateUrl = 'partials/query.editor.html';
|
||||
}
|
||||
|
||||
export {
|
||||
MysqlDatasource,
|
||||
MysqlDatasource as Datasource,
|
||||
MysqlQueryCtrl as QueryCtrl,
|
||||
};
|
||||
|
@@ -0,0 +1,20 @@
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h6>Filters</h6>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">Type</span>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input" ng-model="ctrl.annotation.type" ng-options="f.value as f.text for f in [{text: 'Alert', value: 'alert'}]">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">Max limit</span>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input" ng-model="ctrl.annotation.limit" ng-options="f for f in [10,50,100,200,300,500,1000,2000]">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +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>
|
||||
</div>
|
||||
</query-editor-row>
|
8
public/app/plugins/datasource/mysql/plugin.json
Normal file
8
public/app/plugins/datasource/mysql/plugin.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "MySQL",
|
||||
"id": "mysql",
|
||||
|
||||
"annotations": true,
|
||||
"metrics": true
|
||||
}
|
Reference in New Issue
Block a user