File tree Expand file tree Collapse file tree 1 file changed +28
-6
lines changed
public/app/plugins/datasource/grafana Expand file tree Collapse file tree 1 file changed +28
-6
lines changed Original file line number Diff line number Diff line change 1
1
///<reference path="../../../headers/common.d.ts" />
2
2
3
+ import _ from 'lodash' ;
4
+
3
5
class GrafanaDatasource {
4
6
5
7
/** @ngInject */
6
8
constructor ( private backendSrv ) { }
7
9
8
10
query ( options ) {
9
- return this . backendSrv . get ( '/api/metrics/test' , {
10
- from : options . range . from . valueOf ( ) ,
11
- to : options . range . to . valueOf ( ) ,
12
- scenario : 'random_walk' ,
13
- interval : options . intervalMs ,
14
- maxDataPoints : options . maxDataPoints
11
+ return this . backendSrv . post ( '/api/tsdb/query' , {
12
+ from : options . range . from . valueOf ( ) . toString ( ) ,
13
+ to : options . range . to . valueOf ( ) . toString ( ) ,
14
+ queries : [
15
+ {
16
+ "refId" : "A" ,
17
+ "scenarioId" : "random_walk" ,
18
+ "intervalMs" : options . intervalMs ,
19
+ "maxDataPoints" : options . maxDataPoints ,
20
+ }
21
+ ]
22
+ } ) . then ( res => {
23
+
24
+ var data = [ ] ;
25
+ if ( res . results ) {
26
+ _ . forEach ( res . results , queryRes => {
27
+ for ( let series of queryRes . series ) {
28
+ data . push ( {
29
+ target : series . name ,
30
+ datapoints : series . points
31
+ } ) ;
32
+ }
33
+ } ) ;
34
+ }
35
+
36
+ return { data : data } ;
15
37
} ) ;
16
38
}
17
39
You can’t perform that action at this time.
0 commit comments