-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
60 lines (44 loc) · 1.29 KB
/
main.js
File metadata and controls
60 lines (44 loc) · 1.29 KB
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
var Request = require("request");
var zlib = require("zlib");
var args = process.argv.slice(2);
if(args.length !== 2)
{
console.log("Must specify Insights key and RPM ID");
process.exit(-1);
}
//HTTP Request for API
var queue1Staleness = 1;
var queue2Staleness = 4;
var body = JSON.stringify([
{
"eventType":"RabbitMQStaleEvent",
"AppName": "App1",
"RabbitMQServer": "RabbitMQ1",
"queueName":"Queue1",
"value":queue1Staleness
},
{
"eventType":"RabbitMQStaleEvent",
"AppName": "App1",
"RabbitMQServer": "RabbitMQ1",
"queueName":"Queue2",
"value":queue2Staleness,
"depth": 2000
}
]
)
var insightsURL = "https://insights-collector.newrelic.com/v1/accounts/" +args[1] + "/events";
zlib.gzip(body, function (error, gzipbody) {
if (error) throw error;
console.log(gzipbody);
Request.post({
"headers": {"content-type": "application/json", "X-Insert-Key": args[0], "Content-Encoding": "gzip" },
"url": insightsURL,
"body":gzipbody
}, (error, response, body) => {
if(error) {
return console.dir(error);
}
console.dir(JSON.parse(body));
});
})