-
Notifications
You must be signed in to change notification settings - Fork 0
/
appd-envoy.js
87 lines (80 loc) · 4.03 KB
/
appd-envoy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
'use strict';
// AppDynamics will be configured through env vars
//
module.exports = function(config) {
var appdDebug = false
// var appdReuseNodePrefix = "droid"
if (typeof process.env.PREVIEW_APP != "undefined") {
console.log("appd-envoy: preview app, appdynamics agent not enabled")
} else {
if (process.env.APPDYNAMICS_AGENT_ENABLED == 'true' )
{
if ( typeof process.env.OCT_VAULT_SHARED_READ_APPDYNAMICS_ACCOUNTNAME == "undefined" ) {
console.log("appd-envoy: OCT_VAULT_SHARED_READ_APPDYNAMICS_ACCOUNTNAME not set")
} else {
if (typeof process.env.APPDYNAMICS_AGENT_DEBUG != "undefined") {
appdDebug = process.env.APPDYNAMICS_AGENT_DEBUG
}
else if (typeof config.debug != "undefined") {
appdDebug = config.debug
}
if (appdDebug) { console.log("appdDebug: ", appdDebug, "\n") }
const fs = require('fs')
const os = require('os')
try {
var l = fs.readFileSync('/proc/self/cgroup').toString().split("\n").sort(function (a, b) {
return parseInt(a.split(":")[0]) - parseInt(b.split(":")[0])
})[0].split("/")
var containerId = containerId = l[l.length - 1].substr(0, 12)
process.env.APPDYNAMICS_AGENT_UNIQUE_HOST_ID = containerId
process.env.UNIQUE_HOST_ID = containerId
if (appdDebug) {
console.log("[appd-envoy] APPDYNAMICS_AGENT_UNIQUE_HOST_ID:", process.env.APPDYNAMICS_AGENT_UNIQUE_HOST_ID)
console.log("[appd-envoy] UNIQUE_HOST_ID:", process.env.UNIQUE_HOST_ID)
}
var nodeName = os.hostname().split(".")[0]
var re = "/user|pass|key|secret|private|token|salt|auth|hash/i"
require("appdynamics").profile({
controllerHostName: process.env.OCT_VAULT_SHARED_READ_APPDYNAMICS_CONTROLLERHOSTNAME,
controllerPort: process.env.OCT_VAULT_SHARED_READ_APPDYNAMICS_CONTROLLERPORT,
controllerSslEnabled: process.env.OCT_VAULT_SHARED_READ_APPDYNAMICS_CONTROLLERSSLENABLED,
accountName: process.env.OCT_VAULT_SHARED_READ_APPDYNAMICS_ACCOUNTNAME,
accountAccessKey: process.env.OCT_VAULT_SHARED_READ_APPDYNAMICS_ACCOUNTACCESSKEY,
tierName: process.env.AKKERIS_DEPLOYMENT,
nodeName: nodeName,
uniqueHostId: containerId,
debug: appdDebug,
reuseNode: false,
noNodeNameSuffix: true,
dataFilters: [
{
"appliesTo": "env-vars",
"matchPattern": re
},
{
"appliesTo": "http-headers",
"matchPattern": re
}
],
urlFilters: [{
"delimiter": "/",
"segment": 1,
"matchPattern": "/\@/",
"paramPattern": re
}],
logging: {
logfiles: [{
outputType: 'console'
}]
}
});
console.log("Started appdynamics agent for: %s-%s-%s\n", process.env.APPDYNAMICS_AGENT_APPLICATION_NAME, process.env.AKKERIS_DEPLOYMENT, nodeName)
} catch (err) {
console.error("error configuring appdynamics agent")
console.error(err)
}
}
}
}
return this
}