55 */
66
77import { InfraClientCoreSetup } from '../types' ;
8-
9- // TODO: this satisfies a TS error because TS inference assumed the stat type was just "string",
10- // but we need a better solution for this 🤔
11- type StatType = 'number' | 'percent' | 'bytesPerSecond' ;
8+ import { LogsFetchDataResponse } from '../../../observability/public' ;
129
1310export function getLogsHasDataFetcher ( getStartServices : InfraClientCoreSetup [ 'getStartServices' ] ) {
1411 return async ( ) => {
12+ // if you need the data plugin, this is how you get it
1513 const [ , startPlugins ] = await getStartServices ( ) ;
1614 const { data } = startPlugins ;
15+
16+ // if you need a core dep, we need to pass in more than just getStartServices
17+
1718 // perform query
1819 return true ;
1920 } ;
@@ -22,27 +23,30 @@ export function getLogsHasDataFetcher(getStartServices: InfraClientCoreSetup['ge
2223export function getLogsOverviewDataFetcher (
2324 getStartServices : InfraClientCoreSetup [ 'getStartServices' ]
2425) {
25- return async ( ) => {
26+ return async ( ) : Promise < LogsFetchDataResponse > => {
27+ // if you need the data plugin, this is how you get it
2628 const [ , startPlugins ] = await getStartServices ( ) ;
2729 const { data } = startPlugins ;
2830
31+ // if you need a core dep, we need to pass in more than just getStartServices
32+
2933 // perform query
3034 return {
3135 title : 'Log rate' ,
3236 appLink : 'TBD' , // TODO: what format should this be in, relative I assume?
3337 stats : {
3438 nginx : {
35- type : 'number' as StatType , // TODO: this casting is a hack, we need to fix
39+ type : 'number' ,
3640 label : 'nginx' ,
3741 value : 345341 ,
3842 } ,
3943 'elasticsearch.audit' : {
40- type : 'number' as StatType ,
44+ type : 'number' ,
4145 label : 'elasticsearch.audit' ,
4246 value : 164929 ,
4347 } ,
4448 'haproxy.log' : {
45- type : 'number' as StatType ,
49+ type : 'number' ,
4650 label : 'haproxy.log' ,
4751 value : 51101 ,
4852 } ,
@@ -56,31 +60,31 @@ export function getLogsOverviewDataFetcher(
5660 nginx : {
5761 label : 'nginx' ,
5862 coordinates : [
59- { x : '2020-06-24T12:00:00.000Z' , y : 10014 } ,
60- { x : '2020-06-24T12:15:00.000Z' , y : 12827 } ,
61- { x : '2020-06-24T12:30:00.000Z' , y : 2946 } ,
62- { x : '2020-06-24T12:45:00.000Z' , y : 14298 } ,
63- { x : '2020-06-24T13:00:00.000Z' , y : 4096 } ,
63+ { x : 1593000000000 , y : 10014 } ,
64+ { x : 1593000900000 , y : 12827 } ,
65+ { x : 1593001800000 , y : 2946 } ,
66+ { x : 1593002700000 , y : 14298 } ,
67+ { x : 1593003600000 , y : 4096 } ,
6468 ] ,
6569 } ,
6670 'elasticsearch.audit' : {
6771 label : 'elasticsearch.audit' ,
6872 coordinates : [
69- { x : '2020-06-24T12:00:00.000Z' , y : 5676 } ,
70- { x : '2020-06-24T12:15:00.000Z' , y : 6783 } ,
71- { x : '2020-06-24T12:30:00.000Z' , y : 2394 } ,
72- { x : '2020-06-24T12:45:00.000Z' , y : 4554 } ,
73- { x : '2020-06-24T13:00:00.000Z' , y : 5659 } ,
73+ { x : 1593000000000 , y : 5676 } ,
74+ { x : 1593000900000 , y : 6783 } ,
75+ { x : 1593001800000 , y : 2394 } ,
76+ { x : 1593002700000 , y : 4554 } ,
77+ { x : 1593003600000 , y : 5659 } ,
7478 ] ,
7579 } ,
7680 'haproxy.log' : {
7781 label : 'haproxy.log' ,
7882 coordinates : [
79- { x : '2020-06-24T12:00:00.000Z' , y : 9085 } ,
80- { x : '2020-06-24T12:15:00.000Z' , y : 9002 } ,
81- { x : '2020-06-24T12:30:00.000Z' , y : 3940 } ,
82- { x : '2020-06-24T12:45:00.000Z' , y : 5451 } ,
83- { x : '2020-06-24T13:00:00.000Z' , y : 9133 } ,
83+ { x : 1593000000000 , y : 9085 } ,
84+ { x : 1593000900000 , y : 9002 } ,
85+ { x : 1593001800000 , y : 3940 } ,
86+ { x : 1593002700000 , y : 5451 } ,
87+ { x : 1593003600000 , y : 9133 } ,
8488 ] ,
8589 } ,
8690 } ,
0 commit comments