Merge branch 'master' into backend
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { FC } from 'react';
|
||||
import { css, cx } from 'emotion';
|
||||
import { Themeable, withTheme, Input, EventsWithValidation, ValidationEvents } from '@grafana/ui';
|
||||
import { withTheme, Input, EventsWithValidation, ValidationEvents, Themeable } from '@grafana/ui';
|
||||
import { GrafanaTheme } from '@grafana/data';
|
||||
import { isRegex, variableRegex } from '../utils';
|
||||
|
||||
|
||||
@@ -2,6 +2,14 @@ import _ from 'lodash';
|
||||
import * as utils from './utils';
|
||||
import ts, { groupBy_perf as groupBy } from './timeseries';
|
||||
|
||||
let SUM = ts.SUM;
|
||||
let COUNT = ts.COUNT;
|
||||
let AVERAGE = ts.AVERAGE;
|
||||
let MIN = ts.MIN;
|
||||
let MAX = ts.MAX;
|
||||
let MEDIAN = ts.MEDIAN;
|
||||
let PERCENTILE = ts.PERCENTILE;
|
||||
|
||||
let downsampleSeries = ts.downsample;
|
||||
let groupBy_exported = (interval, groupFunc, datapoints) => groupBy(datapoints, interval, groupFunc);
|
||||
let sumSeries = ts.sumSeries;
|
||||
@@ -11,14 +19,7 @@ let scale = (factor, datapoints) => ts.scale_perf(datapoints, factor);
|
||||
let offset = (delta, datapoints) => ts.offset(datapoints, delta);
|
||||
let simpleMovingAverage = (n, datapoints) => ts.simpleMovingAverage(datapoints, n);
|
||||
let expMovingAverage = (a, datapoints) => ts.expMovingAverage(datapoints, a);
|
||||
|
||||
let SUM = ts.SUM;
|
||||
let COUNT = ts.COUNT;
|
||||
let AVERAGE = ts.AVERAGE;
|
||||
let MIN = ts.MIN;
|
||||
let MAX = ts.MAX;
|
||||
let MEDIAN = ts.MEDIAN;
|
||||
let PERCENTILE = ts.PERCENTILE;
|
||||
let percentile = (interval, n, datapoints) => groupBy(datapoints, interval, _.partial(PERCENTILE, n));
|
||||
|
||||
function limit(order, n, orderByFunc, timeseries) {
|
||||
let orderByCallback = aggregationFunctions[orderByFunc];
|
||||
@@ -120,7 +121,7 @@ function aggregateWrapper(groupByCallback, interval, datapoints) {
|
||||
return groupBy(sortedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function percentile(interval, n, datapoints) {
|
||||
function percentileAgg(interval, n, datapoints) {
|
||||
const flattenedPoints = ts.flattenDatapoints(datapoints);
|
||||
// groupBy_perf works with sorted series only
|
||||
const sortedPoints = ts.sortByTime(flattenedPoints);
|
||||
@@ -153,10 +154,11 @@ let metricFunctions = {
|
||||
rate: rate,
|
||||
movingAverage: simpleMovingAverage,
|
||||
exponentialMovingAverage: expMovingAverage,
|
||||
percentile: percentile,
|
||||
transformNull: transformNull,
|
||||
aggregateBy: aggregateByWrapper,
|
||||
// Predefined aggs
|
||||
percentile: percentile,
|
||||
percentileAgg: percentileAgg,
|
||||
average: _.partial(aggregateWrapper, AVERAGE),
|
||||
min: _.partial(aggregateWrapper, MIN),
|
||||
max: _.partial(aggregateWrapper, MAX),
|
||||
|
||||
@@ -85,6 +85,16 @@ addFuncDef({
|
||||
defaultParams: [0.2],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'percentile',
|
||||
category: 'Transform',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' },
|
||||
{ name: 'percent', type: 'float', options: [25, 50, 75, 90, 95, 99, 99.9] }
|
||||
],
|
||||
defaultParams: ['1m', 95],
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'removeAboveValue',
|
||||
category: 'Transform',
|
||||
@@ -140,7 +150,7 @@ addFuncDef({
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'percentile',
|
||||
name: 'percentileAgg',
|
||||
category: 'Aggregate',
|
||||
params: [
|
||||
{ name: 'interval', type: 'string' },
|
||||
|
||||
@@ -57,30 +57,30 @@ type TimeSeriesPoints = TimePoint[];
|
||||
type TimeSeriesSlice = TimeSeries[];
|
||||
|
||||
interface TimeSeries {
|
||||
name: string;
|
||||
points: TimeSeriesPoints;
|
||||
tags: { [key: string]: string };
|
||||
name: string;
|
||||
points: TimeSeriesPoints;
|
||||
tags: { [key: string]: string };
|
||||
}
|
||||
|
||||
interface TableColumn {
|
||||
text: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface Table {
|
||||
columns: TableColumn[];
|
||||
rows: RowValues[];
|
||||
columns: TableColumn[];
|
||||
rows: RowValues[];
|
||||
}
|
||||
|
||||
interface QueryResult {
|
||||
error: string;
|
||||
refId: string;
|
||||
meta: any;
|
||||
series: TimeSeriesSlice[];
|
||||
tables: Table[];
|
||||
error: string;
|
||||
refId: string;
|
||||
meta: any;
|
||||
series: TimeSeriesSlice[];
|
||||
tables: Table[];
|
||||
}
|
||||
|
||||
export interface TSDBResponse {
|
||||
results: { [key: string]: QueryResult };
|
||||
results: { [key: string]: QueryResult };
|
||||
message: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,10 @@ jest.mock('grafana/app/core/config', () => {
|
||||
|
||||
jest.mock('jquery', () => 'module not found', {virtual: true});
|
||||
|
||||
// jest.mock('@grafana/ui', () => {
|
||||
// return {};
|
||||
// }, {virtual: true});
|
||||
|
||||
// Required for loading angularjs
|
||||
let dom = new JSDOM('<html><head><script></script></head><body></body></html>');
|
||||
// Setup jsdom
|
||||
|
||||
Reference in New Issue
Block a user