mirror of
https://github.com/openziti/zrok.git
synced 2025-06-24 11:41:25 +02:00
parent
044ba042aa
commit
8bd7991b2b
@ -141,20 +141,22 @@ func (mh *metricsHandler) run() {
|
|||||||
}
|
}
|
||||||
mtr := &model.Metrics{}
|
mtr := &model.Metrics{}
|
||||||
if err := bson.Unmarshal(mtrBuf.Bytes(), &mtr); err == nil {
|
if err := bson.Unmarshal(mtrBuf.Bytes(), &mtr); err == nil {
|
||||||
out := "metrics = {\n"
|
|
||||||
var pts []*write.Point
|
var pts []*write.Point
|
||||||
for k, v := range mtr.Sessions {
|
if len(mtr.Sessions) > 0 {
|
||||||
if mh.writeApi != nil {
|
out := "metrics = {\n"
|
||||||
pt := influxdb2.NewPoint("xfer",
|
for k, v := range mtr.Sessions {
|
||||||
map[string]string{"namespace": mtr.Namespace, "session": k},
|
if mh.writeApi != nil {
|
||||||
map[string]interface{}{"bytesRead": v.BytesRead, "bytesWritten": v.BytesWritten},
|
pt := influxdb2.NewPoint("xfer",
|
||||||
time.UnixMilli(v.LastUpdate))
|
map[string]string{"namespace": mtr.Namespace, "session": k},
|
||||||
pts = append(pts, pt)
|
map[string]interface{}{"bytesRead": v.BytesRead, "bytesWritten": v.BytesWritten},
|
||||||
|
time.UnixMilli(v.LastUpdate))
|
||||||
|
pts = append(pts, pt)
|
||||||
|
}
|
||||||
|
out += fmt.Sprintf("\t[%v.%v]: %v/%v (%v)\n", mtr.Namespace, k, util.BytesToSize(v.BytesRead), util.BytesToSize(v.BytesWritten), time.Since(time.UnixMilli(v.LastUpdate)))
|
||||||
}
|
}
|
||||||
out += fmt.Sprintf("\t[%v.%v]: %v/%v\n", mtr.Namespace, k, util.BytesToSize(v.BytesRead), util.BytesToSize(v.BytesWritten))
|
out += "}"
|
||||||
|
logrus.Info(out)
|
||||||
}
|
}
|
||||||
out += "}"
|
|
||||||
logrus.Info(out)
|
|
||||||
|
|
||||||
if len(pts) > 0 {
|
if len(pts) > 0 {
|
||||||
if err := mh.writeApi.WritePoint(context.Background(), pts...); err == nil {
|
if err := mh.writeApi.WritePoint(context.Background(), pts...); err == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user