mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 16:13:47 +01:00
metrics improvements (#234)
This commit is contained in:
parent
d1688c450d
commit
ce4eac8e4c
@ -227,14 +227,21 @@ func runFluxForRxTxArray(query string, queryApi api.QueryAPI) (rx, tx, timestamp
|
|||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
for result.Next() {
|
for result.Next() {
|
||||||
if v, ok := result.Record().Value().(int64); ok {
|
|
||||||
switch result.Record().Field() {
|
switch result.Record().Field() {
|
||||||
case "rx":
|
case "rx":
|
||||||
rx = append(rx, float64(v))
|
rxV := int64(0)
|
||||||
timestamps = append(timestamps, float64(result.Record().Time().UnixMilli()))
|
if v, ok := result.Record().Value().(int64); ok {
|
||||||
case "tx":
|
rxV = v
|
||||||
tx = append(tx, float64(v))
|
|
||||||
}
|
}
|
||||||
|
rx = append(rx, float64(rxV))
|
||||||
|
timestamps = append(timestamps, float64(result.Record().Time().UnixMilli()))
|
||||||
|
|
||||||
|
case "tx":
|
||||||
|
txV := int64(0)
|
||||||
|
if v, ok := result.Record().Value().(int64); ok {
|
||||||
|
txV = v
|
||||||
|
}
|
||||||
|
tx = append(tx, float64(txV))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rx, tx, timestamps, nil
|
return rx, tx, timestamps, nil
|
||||||
@ -245,9 +252,9 @@ func sliceSize(duration time.Duration) time.Duration {
|
|||||||
case 30 * 24 * time.Hour:
|
case 30 * 24 * time.Hour:
|
||||||
return 24 * time.Hour
|
return 24 * time.Hour
|
||||||
case 7 * 24 * time.Hour:
|
case 7 * 24 * time.Hour:
|
||||||
return 20 * time.Minute
|
return 4 * time.Hour
|
||||||
case 24 * time.Hour:
|
case 24 * time.Hour:
|
||||||
return 5 * time.Minute
|
return 30 * time.Minute
|
||||||
default:
|
default:
|
||||||
return duration
|
return duration
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ const MetricsGraph = (props) => {
|
|||||||
<CartesianGrid strokeDasharay={"3 3"} />
|
<CartesianGrid strokeDasharay={"3 3"} />
|
||||||
<XAxis dataKey={(v) => v.timestamp} scale={"time"} tickFormatter={(v) => moment(v).format("MMM DD") } style={{ fontSize: '75%'}}/>
|
<XAxis dataKey={(v) => v.timestamp} scale={"time"} tickFormatter={(v) => moment(v).format("MMM DD") } style={{ fontSize: '75%'}}/>
|
||||||
<YAxis tickFormatter={(v) => bytesToSize(v)} style={{ fontSize: '75%' }}/>
|
<YAxis tickFormatter={(v) => bytesToSize(v)} style={{ fontSize: '75%' }}/>
|
||||||
<Bar stroke={"#231069"} fill={"#04adef"} dataKey={"rx"} />
|
<Bar stroke={"#231069"} fill={"#04adef"} dataKey={(v) => v.rx ? v.rx : 0} />
|
||||||
<Bar stroke={"#231069"} fill={"#9BF316"} dataKey={"tx"} />
|
<Bar stroke={"#231069"} fill={"#9BF316"} dataKey={(v) => v.tx ? v.tx : 0} />
|
||||||
<Tooltip />
|
<Tooltip />
|
||||||
</BarChart>
|
</BarChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export const buildMetrics = (m) => {
|
export const buildMetrics = (m) => {
|
||||||
|
console.log("build", m);
|
||||||
let metrics = {
|
let metrics = {
|
||||||
data: m.samples,
|
data: m.samples,
|
||||||
rx: 0,
|
rx: 0,
|
||||||
@ -6,8 +7,8 @@ export const buildMetrics = (m) => {
|
|||||||
}
|
}
|
||||||
if(m.samples) {
|
if(m.samples) {
|
||||||
m.samples.forEach(s => {
|
m.samples.forEach(s => {
|
||||||
metrics.rx += s.rx;
|
metrics.rx += s.rx ? s.rx : 0;
|
||||||
metrics.tx += s.tx;
|
metrics.tx += s.tx ? s.tx : 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return metrics;
|
return metrics;
|
||||||
|
Loading…
Reference in New Issue
Block a user