mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'master' into popover-forms
This commit is contained in:
@@ -5,38 +5,16 @@ import _ from 'lodash';
|
||||
class GrafanaDatasource {
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private backendSrv) {}
|
||||
constructor(private backendSrv, private $q) {}
|
||||
|
||||
query(options) {
|
||||
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};
|
||||
});
|
||||
return this.$q.when({data: []});
|
||||
}
|
||||
|
||||
metricFindQuery() {
|
||||
return this.$q.when([]);
|
||||
};
|
||||
|
||||
annotationQuery(options) {
|
||||
return this.backendSrv.get('/api/annotations', {
|
||||
from: options.range.from.valueOf(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "Grafana",
|
||||
"name": "-- Grafana --",
|
||||
"id": "grafana",
|
||||
|
||||
"builtIn": true,
|
||||
|
||||
@@ -193,8 +193,17 @@ export default class InfluxDatasource {
|
||||
}
|
||||
|
||||
testDatasource() {
|
||||
return this.metricFindQuery('SHOW MEASUREMENTS LIMIT 1').then(() => {
|
||||
return this.metricFindQuery('SHOW DATABASES').then(res => {
|
||||
let found = _.find(res, {text: this.database});
|
||||
if (!found) {
|
||||
return { status: "error", message: "Could not find the specified database name.", title: "DB Not found" };
|
||||
}
|
||||
return { status: "success", message: "Data source is working", title: "Success" };
|
||||
}).catch(err => {
|
||||
if (err.data && err.message) {
|
||||
return { status: "error", message: err.data.message, title: "InfluxDB Error" };
|
||||
}
|
||||
return { status: "error", message: err.toString(), title: "InfluxDB Error" };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ var categories = {
|
||||
Aggregations: [],
|
||||
Selectors: [],
|
||||
Transformations: [],
|
||||
Predictors: [],
|
||||
Math: [],
|
||||
Aliasing: [],
|
||||
Fields: [],
|
||||
@@ -233,7 +234,7 @@ register({
|
||||
type: 'moving_average',
|
||||
addStrategy: addTransformationStrategy,
|
||||
category: categories.Transformations,
|
||||
params: [{ name: "window", type: "number", options: [5, 10, 20, 30, 40]}],
|
||||
params: [{ name: "window", type: "int", options: [5, 10, 20, 30, 40]}],
|
||||
defaultParams: [10],
|
||||
renderer: functionRenderer,
|
||||
});
|
||||
@@ -259,8 +260,8 @@ register({
|
||||
register({
|
||||
type: 'time',
|
||||
category: groupByTimeFunctions,
|
||||
params: [{ name: "interval", type: "time", options: ['auto', '1s', '10s', '1m', '5m', '10m', '15m', '1h'] }],
|
||||
defaultParams: ['auto'],
|
||||
params: [{ name: "interval", type: "time", options: ['$__interval', '1s', '10s', '1m', '5m', '10m', '15m', '1h']}],
|
||||
defaultParams: ['$__interval'],
|
||||
renderer: functionRenderer,
|
||||
});
|
||||
|
||||
@@ -281,6 +282,25 @@ register({
|
||||
renderer: functionRenderer,
|
||||
});
|
||||
|
||||
// predictions
|
||||
register({
|
||||
type: 'holt_winters',
|
||||
addStrategy: addTransformationStrategy,
|
||||
category: categories.Predictors,
|
||||
params: [{ name: "number", type: "int", options: [5, 10, 20, 30, 40]}, { name: "season", type: "int", options: [0, 1, 2, 5, 10]}],
|
||||
defaultParams: [10, 2],
|
||||
renderer: functionRenderer,
|
||||
});
|
||||
|
||||
register({
|
||||
type: 'holt_winters_with_fit',
|
||||
addStrategy: addTransformationStrategy,
|
||||
category: categories.Predictors,
|
||||
params: [{ name: "number", type: "int", options: [5, 10, 20, 30, 40]}, { name: "season", type: "int", options: [0, 1, 2, 5, 10]}],
|
||||
defaultParams: [10, 2],
|
||||
renderer: functionRenderer,
|
||||
});
|
||||
|
||||
// Selectors
|
||||
register({
|
||||
type: 'bottom',
|
||||
|
||||
@@ -123,8 +123,7 @@ describe('InfluxQuery', function() {
|
||||
}, templateSrv, {});
|
||||
|
||||
var queryText = query.render();
|
||||
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter ' +
|
||||
'GROUP BY time($__interval), "host"');
|
||||
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter GROUP BY time($__interval), "host"');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "Mixed datasource",
|
||||
"name": "-- Mixed --",
|
||||
"id": "mixed",
|
||||
|
||||
"builtIn": true,
|
||||
|
||||
Reference in New Issue
Block a user