8
8
# HUBOT_NEWRELIC_ACCOUNT_ID
9
9
# HUBOT_NEWRELIC_APP_ID
10
10
# HUBOT_NEWRELIC_API_KEY
11
- #
11
+ #
12
12
# Commands:
13
13
# hubot newrelic me - Returns summary application stats from New Relic
14
14
#
18
18
# Given: https://rpm.newrelic.com/accounts/xxx/applications/yyy
19
19
# xxx is your Account ID and yyy is your App ID
20
20
# Account Settings > API + Web Integrations > API Access > "API key"
21
- #
21
+ #
22
22
# Author:
23
23
# briandoll
24
24
25
25
module .exports = (robot ) ->
26
- robot .respond / newrelic me/ i , (msg ) ->
27
- accountId = process .env .HUBOT_NEWRELIC_ACCOUNT_ID
28
- appId = process .env .HUBOT_NEWRELIC_APP_ID
29
- apiKey = process .env .HUBOT_NEWRELIC_API_KEY
30
- Parser = require (" xml2js" ).Parser
31
-
26
+ fetchData = (appId ) ->
32
27
msg .http (" https://rpm.newrelic.com/accounts/#{ accountId} /applications/#{ appId} /threshold_values?api_key=#{ apiKey} " )
33
28
.get () (err , res , body ) ->
34
29
if err
@@ -39,5 +34,13 @@ module.exports = (robot) ->
39
34
threshold_values = json[' threshold-values' ][' threshold_value' ] || []
40
35
lines = threshold_values .map (threshold_value) ->
41
36
" #{ threshold_value[' $' ][' name' ]} : #{ threshold_value[' $' ][' formatted_metric_value' ]} "
42
-
37
+
43
38
msg .send lines .join (" \n " ), " https://rpm.newrelic.com/accounts/#{ accountId} /applications/#{ appId} "
39
+
40
+ robot .respond / newrelic me/ i , (msg ) ->
41
+ accountId = process .env .HUBOT_NEWRELIC_ACCOUNT_ID
42
+ appIds = process .env .HUBOT_NEWRELIC_APP_ID .split (' ,' )
43
+ apiKey = process .env .HUBOT_NEWRELIC_API_KEY
44
+ Parser = require (" xml2js" ).Parser
45
+ fetchData (appId) for appId in appIds
46
+
0 commit comments