-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.mjs
More file actions
104 lines (97 loc) · 13.3 KB
/
Copy pathindex.mjs
File metadata and controls
104 lines (97 loc) · 13.3 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import * as echarts from 'https://cdn.jsdelivr.net/npm/echarts@5.2.2/dist/echarts.esm.min.js'
const prometheusQueryResponse =
{
"status": "success", "data": {
"resultType": "matrix", "result": [{
"metric": {"job": "prometheus"},
"values": [[1637247177.952, "0.00007350333333333339"], [1637247191.952, "0.00007350333333333339"], [1637247205.952, "0.00006207000000000001"], [1637247219.952, "0.00006207000000000001"], [1637247233.952, "0.00006207000000000001"], [1637247247.952, "0.00006207000000000001"], [1637247261.952, "0.00006207000000000001"], [1637247275.952, "0.00005853333333333338"], [1637247289.952, "0.00005853333333333338"], [1637247303.952, "0.00005853333333333338"], [1637247317.952, "0.000055300000000000104"], [1637247331.952, "0.000055300000000000104"], [1637247345.952, "0.000055300000000000104"], [1637247359.952, "0.000055300000000000104"], [1637247373.952, "0.000055300000000000104"], [1637247387.952, "0.000055300000000000104"], [1637247401.952, "0.00007813333333333334"], [1637247415.952, "0.00007813333333333334"], [1637247429.952, "0.00007813333333333334"], [1637247443.952, "0.00008763"], [1637247457.952, "0.00008763"], [1637247471.952, "0.00008763"], [1637247485.952, "0.00008763"], [1637247499.952, "0.00008763"], [1637247513.952, "0.00008763"], [1637247527.952, "0.00007079333333333329"], [1637247541.952, "0.00007079333333333329"], [1637247555.952, "0.00007079333333333329"], [1637247569.952, "0.00008045999999999986"], [1637247583.952, "0.00008045999999999986"], [1637247597.952, "0.00008045999999999986"], [1637247611.952, "0.00008045999999999986"], [1637247625.952, "0.00008045999999999986"], [1637247639.952, "0.00008045999999999986"], [1637247653.952, "0.00007168999999999997"], [1637247667.952, "0.00007168999999999997"], [1637247681.952, "0.00004563500000000004"], [1637247695.952, "0.00004563500000000004"], [1637247709.952, "0.00004563500000000004"], [1637247723.952, "0.00004563500000000004"], [1637247737.952, "0.00004563500000000004"], [1637247751.952, "0.00004563500000000004"], [1637247765.952, "0.00004563500000000004"], [1637247779.952, "0.000051676666666666666"], [1637247793.952, "0.000051676666666666666"], [1637247807.952, "0.000051676666666666666"], [1637247821.952, "0.00005895500000000009"], [1637247835.952, "0.00005895500000000009"], [1637247849.952, "0.00005895500000000009"], [1637247863.952, "0.00005895500000000009"], [1637247877.952, "0.00005895500000000009"], [1637247891.952, "0.00006399666666666664"], [1637247905.952, "0.00006399666666666664"], [1637247919.952, "0.00006399666666666664"], [1637247933.952, "0.00006891999999999988"], [1637247947.952, "0.00006891999999999988"], [1637247961.952, "0.00006891999999999988"], [1637247975.952, "0.00006891999999999988"], [1637247989.952, "0.00006891999999999988"], [1637248003.952, "0.00006891999999999988"], [1637248017.952, "0.00006891999999999988"], [1637248031.952, "0.00008916033333333331"], [1637248045.952, "0.00008916033333333331"], [1637248059.952, "0.0001018605"], [1637248073.952, "0.0001018605"], [1637248087.952, "0.0001018605"], [1637248101.952, "0.0001018605"], [1637248115.952, "0.0001018605"], [1637248129.952, "0.0001018605"], [1637248143.952, "0.00007999033333333326"], [1637248157.952, "0.00007999033333333326"], [1637248171.952, "0.00008294550000000002"], [1637248185.952, "0.00008294550000000002"], [1637248199.952, "0.00008294550000000002"], [1637248213.952, "0.00008294550000000002"], [1637248227.952, "0.00008294550000000002"], [1637248241.952, "0.00008294550000000002"], [1637248255.952, "0.00008294550000000002"], [1637248269.952, "0.00006698033333333335"], [1637248283.952, "0.00006698033333333335"], [1637248297.952, "0.00006698033333333335"], [1637248311.952, "0.000035649999999999925"], [1637248325.952, "0.000035649999999999925"], [1637248339.952, "0.000035649999999999925"], [1637248353.952, "0.000035649999999999925"], [1637248367.952, "0.000035649999999999925"], [1637248381.952, "0.0000439466666666666"], [1637248395.952, "0.0000439466666666666"], [1637248409.952, "0.0000439466666666666"], [1637248423.952, "0.0000439466666666666"], [1637248437.952, "0.000047795"], [1637248451.952, "0.000047795"], [1637248465.952, "0.000047795"], [1637248479.952, "0.000047795"], [1637248493.952, "0.000047795"], [1637248507.952, "0.00004489333333333343"], [1637248521.952, "0.00004489333333333343"], [1637248535.952, "0.00004489333333333343"], [1637248549.952, "0.000049815000000000146"], [1637248563.952, "0.000049815000000000146"], [1637248577.952, "0.000049815000000000146"], [1637248591.952, "0.000049815000000000146"], [1637248605.952, "0.000049815000000000146"], [1637248619.952, "0.000049815000000000146"], [1637248633.952, "0.000044470000000000006"], [1637248647.952, "0.000044470000000000006"], [1637248661.952, "0.000044470000000000006"], [1637248675.952, "0.000036435000000000026"], [1637248689.952, "0.000036435000000000026"], [1637248703.952, "0.000036435000000000026"], [1637248717.952, "0.000036435000000000026"], [1637248731.952, "0.000036435000000000026"], [1637248745.952, "0.00003708333333333341"], [1637248759.952, "0.00003708333333333341"], [1637248773.952, "0.00003708333333333341"], [1637248787.952, "0.00003607999999999997"], [1637248801.952, "0.00003607999999999997"], [1637248815.952, "0.00003607999999999997"], [1637248829.952, "0.00003607999999999997"], [1637248843.952, "0.00003607999999999997"], [1637248857.952, "0.00003607999999999997"], [1637248871.952, "0.000049976666666666645"], [1637248885.952, "0.000049976666666666645"], [1637248899.952, "0.000049976666666666645"], [1637248913.952, "0.00005807500000000009"], [1637248927.952, "0.00005807500000000009"], [1637248941.952, "0.00005807500000000009"], [1637248955.952, "0.00005807500000000009"], [1637248969.952, "0.00005807500000000009"], [1637248983.952, "0.00005807500000000009"], [1637248997.952, "0.00005307966666666675"], [1637249011.952, "0.00005307966666666675"], [1637249025.952, "0.00005307966666666675"], [1637249039.952, "0.00006042950000000004"], [1637249053.952, "0.00006042950000000004"], [1637249067.952, "0.00006042950000000004"], [1637249081.952, "0.00006042950000000004"], [1637249095.952, "0.00006042950000000004"], [1637249109.952, "0.00006042950000000004"], [1637249123.952, "0.0000511763333333333"], [1637249137.952, "0.0000511763333333333"], [1637249151.952, "0.00003787949999999995"], [1637249165.952, "0.00003787949999999995"], [1637249179.952, "0.00003787949999999995"], [1637249193.952, "0.00003787949999999995"], [1637249207.952, "0.00003787949999999995"], [1637249221.952, "0.00003787949999999995"], [1637249235.952, "0.00003787949999999995"], [1637249249.952, "0.00006416666666666665"], [1637249263.952, "0.00006416666666666665"], [1637249277.952, "0.00006416666666666665"], [1637249291.952, "0.00007470549999999996"], [1637249305.952, "0.00007470549999999996"], [1637249319.952, "0.00007470549999999996"], [1637249333.952, "0.00007470549999999996"], [1637249347.952, "0.00007470549999999996"], [1637249361.952, "0.0001464769999999999"], [1637249375.952, "0.0001464769999999999"], [1637249389.952, "0.0001464769999999999"], [1637249403.952, "0.00020338049999999995"], [1637249417.952, "0.00020338049999999995"], [1637249431.952, "0.00020338049999999995"], [1637249445.952, "0.00020338049999999995"], [1637249459.952, "0.00020338049999999995"], [1637249473.952, "0.00020338049999999995"], [1637249487.952, "0.00020338049999999995"], [1637249501.952, "0.00023673700000000002"], [1637249515.952, "0.00023673700000000002"], [1637249529.952, "0.000296735"], [1637249543.952, "0.000296735"], [1637249557.952, "0.000296735"], [1637249571.952, "0.000296735"], [1637249585.952, "0.000296735"], [1637249599.952, "0.000296735"], [1637249613.952, "0.0002101866666666667"], [1637249627.952, "0.0002101866666666667"], [1637249641.952, "0.00017027000000000014"], [1637249655.952, "0.00017027000000000014"], [1637249669.952, "0.00017027000000000014"], [1637249683.952, "0.00017027000000000014"], [1637249697.952, "0.00017027000000000014"], [1637249711.952, "0.00017027000000000014"], [1637249725.952, "0.00017027000000000014"], [1637249739.952, "0.0001419333333333335"], [1637249753.952, "0.0001419333333333335"], [1637249767.952, "0.0001419333333333335"], [1637249781.952, "0.00006117500000000012"], [1637249795.952, "0.00006117500000000012"], [1637249809.952, "0.00006117500000000012"], [1637249823.952, "0.00006117500000000012"], [1637249837.952, "0.00006117500000000012"], [1637249851.952, "0.00006116333333333324"], [1637249865.952, "0.00006116333333333324"], [1637249879.952, "0.00006116333333333324"], [1637249893.952, "0.00006116333333333324"], [1637249907.952, "0.00007319999999999983"], [1637249921.952, "0.00007319999999999983"], [1637249935.952, "0.00007319999999999983"], [1637249949.952, "0.00007319999999999983"], [1637249963.952, "0.00007319999999999983"], [1637249977.952, "0.00012221300000000006"], [1637249991.952, "0.00012221300000000006"], [1637250005.952, "0.00012221300000000006"], [1637250019.952, "0.00014068950000000003"], [1637250033.952, "0.00014068950000000003"], [1637250047.952, "0.00014068950000000003"], [1637250061.952, "0.00014068950000000003"], [1637250075.952, "0.00014068950000000003"], [1637250089.952, "0.00014068950000000003"], [1637250103.952, "0.00011779966666666664"], [1637250117.952, "0.00011779966666666664"], [1637250131.952, "0.00011779966666666664"], [1637250145.952, "0.00014612950000000022"], [1637250159.952, "0.00014612950000000022"], [1637250173.952, "0.00014612950000000022"], [1637250187.952, "0.00014612950000000022"], [1637250201.952, "0.00014612950000000022"], [1637250215.952, "0.00014612950000000022"], [1637250229.952, "0.00011752633333333348"], [1637250243.952, "0.00011752633333333348"], [1637250257.952, "0.00006616999999999994"], [1637250271.952, "0.00006616999999999994"], [1637250285.952, "0.00006616999999999994"], [1637250299.952, "0.00006616999999999994"], [1637250313.952, "0.00006616999999999994"], [1637250327.952, "0.00006616999999999994"], [1637250341.952, "0.00006616999999999994"], [1637250355.952, "0.00006942000000000001"], [1637250369.952, "0.00006942000000000001"], [1637250383.952, "0.00006812000000000007"], [1637250397.952, "0.00006812000000000007"], [1637250411.952, "0.00006812000000000007"], [1637250425.952, "0.00006812000000000007"], [1637250439.952, "0.00006812000000000007"], [1637250453.952, "0.00006812000000000007"], [1637250467.952, "0.00006846666666666655"], [1637250481.952, "0.00006846666666666655"], [1637250495.952, "0.00006846666666666655"], [1637250509.952, "0.00006846666666666655"], [1637250523.952, "0.00007253999999999984"], [1637250537.952, "0.00007253999999999984"], [1637250551.952, "0.00007253999999999984"], [1637250565.952, "0.00007253999999999984"], [1637250579.952, "0.00007253999999999984"], [1637250593.952, "0.00007370333333333334"], [1637250607.952, "0.00007370333333333334"], [1637250621.952, "0.00007370333333333334"], [1637250635.952, "0.00007259499999999996"], [1637250649.952, "0.00007259499999999996"], [1637250663.952, "0.00007259499999999996"], [1637250677.952, "0.00007259499999999996"], [1637250691.952, "0.00007259499999999996"], [1637250705.952, "0.00007259499999999996"], [1637250719.952, "0.00007944333333333308"], [1637250733.952, "0.00007944333333333308"], [1637250747.952, "0.00007944333333333308"], [1637250761.952, "0.00008458499999999987"], [1637250775.952, "0.00008458499999999987"]]
}]
}
}
function getName(result) {
const labels = []
for(let key in result.metric) {
if (result.metric.hasOwnProperty(key)) {
labels.push(`${key}=${result.metric[key]}`)
}
}
return labels.join(" ")
}
const legend = prometheusQueryResponse.data.result.map(result => {
return getName(result);
})
const data = prometheusQueryResponse.data.result[0].values.map(d => {
return [d[0] * 1000, d[1]];
})
const series = prometheusQueryResponse.data.result.map(result => {
const name = getName(result)
const data = result.values.map(d => {
return [d[0] * 1000, d[1] * 1000];
});
return {
name,
type: 'line',
smooth: true,
symbol: 'none',
areaStyle: {},
xAxis: {
type: 'time',
boundaryGap: false
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%']
},
data: data
};
})
function initEcharts() {
var myChart = echarts.init(document.getElementById('main'));
// 绘制图表
myChart.setOption({
tooltip: {
trigger: 'axis',
position: function (pt) {
return [pt[0], '10%'];
}
},
title: {
left: 'center',
text: 'gc_seconds'
},
legend: {
orient: 'horizontal',
top: 'bottom',
left: '10%',
data: legend
},
grid: {
show: true,
backgroundColor: '#b50000'
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'time',
boundaryGap: false,
axisLabel: {
// formatter: function(value, index) {
// return new Date(value).toString();
// },
interval: 'auto'
},
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%'],
axisLabel: {
formatter: '{value} ms'
}
},
series: [series[0], series[0]]
});
}
export default initEcharts;