File tree Expand file tree Collapse file tree 5 files changed +12
-1
lines changed Expand file tree Collapse file tree 5 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ interface MetricObject {
25
25
value : number ;
26
26
__v : number ;
27
27
_id : string ;
28
+ token : string ;
28
29
}
29
30
interface HealthDataObject {
30
31
[ key : string ] : MetricObject [ ] ;
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ interface MetricObject {
30
30
value : number ;
31
31
__v : number ;
32
32
_id : string ;
33
+ token : string ;
33
34
}
34
35
interface HealthDataObject {
35
36
[ key : string ] : MetricObject [ ]
Original file line number Diff line number Diff line change @@ -9,4 +9,4 @@ const GrafanaAPIKeySchema = new Schema({
9
9
}
10
10
} )
11
11
12
- export default mongoose . model ( 'kafgrafanaAPI ' , GrafanaAPIKeySchema ) ;
12
+ export default mongoose . model ( 'grafanaAPI ' , GrafanaAPIKeySchema ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ const HealthSchema = new Schema({
17
17
type : String ,
18
18
default : '' ,
19
19
} ,
20
+ token : {
21
+ type : String ,
22
+ default : '' ,
23
+ } ,
20
24
} ) ;
21
25
22
26
const HealthModelFunc = ( serviceName : string ) => mongoose . model < any > ( serviceName , HealthSchema ) ;
Original file line number Diff line number Diff line change 1
1
import KafkaModel from '../models/KafkaModel' ;
2
2
import HealthModelFunc from '../models/HealthModel' ;
3
3
import { Pool } from 'pg' ;
4
+ import GrafanaAPIKeyModel from '../models/GrafanaAPIKeyModel' ;
4
5
5
6
interface fetchData {
6
7
mongoFetch : ( serviceName : string ) => Promise < Array < { [ key : string ] : any [ ] } > > ;
@@ -33,7 +34,11 @@ const mongoFetch = async (
33
34
) : Promise < Array < { [ key : string ] : any [ ] } > | undefined > => {
34
35
try {
35
36
const testModel = HealthModelFunc ( serviceName ) ;
37
+ const grafanaAPIKey = await GrafanaAPIKeyModel . find ( { } ) ;
36
38
let result = await testModel . aggregate ( aggregator ) ;
39
+ for ( let i = 0 ; i < result . length ; i ++ ) {
40
+ result [ i ] . token = grafanaAPIKey [ 0 ] . token ;
41
+ }
37
42
result = [ { [ serviceName ] : result } ] ;
38
43
return result ;
39
44
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments