File tree Expand file tree Collapse file tree 2 files changed +77
-3
lines changed Expand file tree Collapse file tree 2 files changed +77
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { options , baseURL } from './requestOptions'
2
+ import querystring from 'querystring'
3
+ import rp from 'request-promise'
4
+
5
+ const METRIC_PATH = 'Business Transaction Performance|Business Transactions'
6
+ const METRIC_PATH_ENCODED = querystring . stringify ( {
7
+ 'metric-path' : METRIC_PATH ,
8
+ } )
9
+
10
+ export default async ( ) => {
11
+ return await rp ( {
12
+ ...options ,
13
+ url : `${ baseURL } /rest/applications/64/metrics?output=json&${ METRIC_PATH_ENCODED } ` ,
14
+ } )
15
+ . promise ( )
16
+ . then ( data => {
17
+ const parsedData = JSON . parse ( data )
18
+ const folderNames = parsedData
19
+ . filter ( ( { type } ) => type === 'folder' )
20
+ . map ( ( { name } ) => name )
21
+ return folderNames
22
+ } )
23
+ . catch ( err => {
24
+ console . log ( err )
25
+ } )
26
+ }
27
+
28
+ // First level hierarchy
29
+ // [
30
+ // {
31
+ // "name": "Errors",
32
+ // "type": "folder"
33
+ // },
34
+ // {
35
+ // "name": "Overall Application Performance",
36
+ // "type": "folder"
37
+ // },
38
+ // {
39
+ // "name": "Mobile",
40
+ // "type": "folder"
41
+ // },
42
+ // {
43
+ // "name": "Information Points",
44
+ // "type": "folder"
45
+ // },
46
+ // {
47
+ // "name": "Application Infrastructure Performance",
48
+ // "type": "folder"
49
+ // },
50
+ // {
51
+ // "name": "Business Transaction Performance",
52
+ // "type": "folder"
53
+ // },
54
+ // {
55
+ // "name": "End User Experience",
56
+ // "type": "folder"
57
+ // },
58
+ // {
59
+ // "name": "Backends",
60
+ // "type": "folder"
61
+ // },
62
+ // {
63
+ // "name": "Service Endpoints",
64
+ // "type": "folder"
65
+ // }
66
+ // ]
Original file line number Diff line number Diff line change 1
1
import existingDash from '../existing_dash.json'
2
2
import createDashboard from './createDashboard'
3
+ import getBTNames from './getBTNames'
3
4
4
- const DASHBOARD_NAME = 'z_dan_1111'
5
- const dashObj = { ...existingDash , DASHBOARD_NAME }
5
+ const main = async ( ) => {
6
+ const DASHBOARD_NAME = 'z_dan_1111'
7
+ const dashObj = { ...existingDash , DASHBOARD_NAME }
6
8
7
- createDashboard ( { dashObj } )
9
+ const btNames = await getBTNames ( )
10
+ console . log ( btNames )
11
+
12
+ // createDashboard({ dashObj })
13
+ }
14
+
15
+ main ( )
You can’t perform that action at this time.
0 commit comments