Skip to content

Commit 0c14cfb

Browse files
author
Daniel Arrizza
committed
get metric paths
1 parent 3f4b0ad commit 0c14cfb

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

src/getBTNames.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
// ]

src/main.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import existingDash from '../existing_dash.json'
22
import createDashboard from './createDashboard'
3+
import getBTNames from './getBTNames'
34

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 }
68

7-
createDashboard({ dashObj })
9+
const btNames = await getBTNames()
10+
console.log(btNames)
11+
12+
// createDashboard({ dashObj })
13+
}
14+
15+
main()

0 commit comments

Comments
 (0)