forked from siimon/prom-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistogram-3.js
42 lines (33 loc) · 1.29 KB
/
histogram-3.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
'use strict';
// Histogram
// Multiple Labels
// Single Value per Label
const { register, Histogram } = require('..');
const h = new Histogram({
name: 'test_histogram',
help: 'Example of a histogram',
labelNames: ['code', 'color'],
});
h.labels('200', 'blue').observe(0.4);
h.labels('200', 'blue').observe(0.6);
h.observe({ code: '200', color: 'blue' }, 0.4);
register.metrics().then(str => console.log(str));
/*
Output from metrics():
# HELP test_histogram Example of a histogram
# TYPE test_histogram histogram
test_histogram_bucket{le="0.005",code="200",color="blue"} 0
test_histogram_bucket{le="0.01",code="200",color="blue"} 0
test_histogram_bucket{le="0.025",code="200",color="blue"} 0
test_histogram_bucket{le="0.05",code="200",color="blue"} 0
test_histogram_bucket{le="0.1",code="200",color="blue"} 0
test_histogram_bucket{le="0.25",code="200",color="blue"} 0
test_histogram_bucket{le="0.5",code="200",color="blue"} 2
test_histogram_bucket{le="1",code="200",color="blue"} 3
test_histogram_bucket{le="2.5",code="200",color="blue"} 3
test_histogram_bucket{le="5",code="200",color="blue"} 3
test_histogram_bucket{le="10",code="200",color="blue"} 3
test_histogram_bucket{le="+Inf",code="200",color="blue"} 3
test_histogram_sum{code="200",color="blue"} 1.4
test_histogram_count{code="200",color="blue"} 3
*/