forked from StreamMachine/prometheus_client_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounterAndGauge.js
37 lines (30 loc) · 906 Bytes
/
counterAndGauge.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
// Increment a counter every 10ms
var Prometheus = require("prometheus-client");
var client = new Prometheus();
var counter = client.newCounter({
namespace: "counter_test",
name: "elapsed_counters_total",
help: "The number of counter intervals that have elapsed."
});
gauge = client.newGauge({
namespace: "counter_test",
name: "random_number",
help: "A random number we occasionally set."
});
setInterval(function() {
counter.increment({
period: "1sec" //period is a custom label name in this case with a value of "1sec"
});
}, 1000);
setInterval(function() {
counter.increment({
period: "2sec" //creating a new series with a period label of "2sec"
});
}, 2000);
setInterval(function() {
gauge.set({
period: "1sec"
}, Math.random() * 1000);
}, 1000);
//tell our client to set up a server on the given port
client.listen(9010);