mirror of
https://github.com/openziti/zrok.git
synced 2025-02-16 18:20:51 +01:00
improved ingest logging
This commit is contained in:
parent
15ee4396f4
commit
446485d74c
@ -17,10 +17,10 @@ func Ingest(event ZitiEventJson) (*Usage, error) {
|
||||
if vFloat64, ok := v.(float64); ok {
|
||||
u.IntervalStart = time.Unix(int64(vFloat64), 0)
|
||||
} else {
|
||||
logrus.Error("unable to assert 'interval_start_utc'")
|
||||
logrus.Errorf("unable to assert 'interval_start_utc': %v", event)
|
||||
}
|
||||
} else {
|
||||
logrus.Error("missing 'interval_start_utc'")
|
||||
logrus.Errorf("missing 'interval_start_utc': %v", event)
|
||||
}
|
||||
if v, found := eventMap["tags"]; found {
|
||||
if tags, ok := v.(map[string]interface{}); ok {
|
||||
@ -28,16 +28,16 @@ func Ingest(event ZitiEventJson) (*Usage, error) {
|
||||
if vStr, ok := v.(string); ok {
|
||||
u.ZitiServiceId = vStr
|
||||
} else {
|
||||
logrus.Error("unable to assert 'tags/serviceId'")
|
||||
logrus.Errorf("unable to assert 'tags/serviceId': %v", event)
|
||||
}
|
||||
} else {
|
||||
logrus.Error("missing 'tags/serviceId'")
|
||||
logrus.Errorf("missing 'tags/serviceId': %v", event)
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("unable to assert 'tags'")
|
||||
logrus.Errorf("unable to assert 'tags': %v", event)
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("missing 'tags'")
|
||||
logrus.Errorf("missing 'tags': %v", event)
|
||||
}
|
||||
if v, found := eventMap["usage"]; found {
|
||||
if usage, ok := v.(map[string]interface{}); ok {
|
||||
@ -45,47 +45,47 @@ func Ingest(event ZitiEventJson) (*Usage, error) {
|
||||
if vFloat64, ok := v.(float64); ok {
|
||||
u.FrontendTx = int64(vFloat64)
|
||||
} else {
|
||||
logrus.Error("unable to assert 'usage/ingress.tx'")
|
||||
logrus.Errorf("unable to assert 'usage/ingress.tx': %v", event)
|
||||
}
|
||||
}
|
||||
if v, found := usage["ingress.rx"]; found {
|
||||
if vFloat64, ok := v.(float64); ok {
|
||||
u.FrontendRx = int64(vFloat64)
|
||||
} else {
|
||||
logrus.Error("unable to assert 'usage/ingress.rx")
|
||||
logrus.Errorf("unable to assert 'usage/ingress.rx': %v", event)
|
||||
}
|
||||
}
|
||||
if v, found := usage["egress.tx"]; found {
|
||||
if vFloat64, ok := v.(float64); ok {
|
||||
u.BackendTx = int64(vFloat64)
|
||||
} else {
|
||||
logrus.Error("unable to assert 'usage/egress.tx'")
|
||||
logrus.Errorf("unable to assert 'usage/egress.tx': %v", event)
|
||||
}
|
||||
}
|
||||
if v, found := usage["egress.rx"]; found {
|
||||
if vFloat64, ok := v.(float64); ok {
|
||||
u.BackendRx = int64(vFloat64)
|
||||
} else {
|
||||
logrus.Error("unable to assert 'usage/egress.rx'")
|
||||
logrus.Errorf("unable to assert 'usage/egress.rx': %v", event)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("unable to assert 'usage' (%v) %v", reflect.TypeOf(v), event)
|
||||
}
|
||||
} else {
|
||||
logrus.Warnf("missing 'usage'")
|
||||
logrus.Warnf("missing 'usage': %v", event)
|
||||
}
|
||||
if v, found := eventMap["circuit_id"]; found {
|
||||
if vStr, ok := v.(string); ok {
|
||||
u.ZitiCircuitId = vStr
|
||||
} else {
|
||||
logrus.Error("unable to assert 'circuit_id'")
|
||||
logrus.Errorf("unable to assert 'circuit_id': %v", event)
|
||||
}
|
||||
} else {
|
||||
logrus.Warn("missing 'circuit_id'")
|
||||
logrus.Warnf("missing 'circuit_id': %v", event)
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("not 'fabric.usage'")
|
||||
logrus.Errorf("not 'fabric.usage': %v", event)
|
||||
}
|
||||
return u, nil
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user