Hi TC,
One way you could retrieve the data consumed between two messages is by doing the following for each radius packet:
- initialize a temporary variable in which you store the sum of the input and output octets from the packet that is being processed at that moment;
- compute your desired value as a difference between the current sum from the previous step and the cached sum of the packet processed before this, if it exists;
- store the variable created in the first step in the cache, to help determine the difference when processing the next packet.
To make things clearer, I updated the request processor you provided:
"id": "MktUpdate",
"tenant" : "WiFi",
"filters": ["*string:~*req.Acct-Status-Type:Interim-Update"],
"flags": ["*update", "*accounts", "*attributes", "*continue"],
"request_fields":[
// create the temporary variable with the octets sum (path should begin with *tmp since it can be discarded after every process)
{"path": "*tmp.InputOutputSum", "type": "*sum", "value": "~*req.Acct-Input-Octets;~*req.Acct-Output-Octets"},
// calculate the difference between this sum and the previous one if it exists. You can check this by using a filter of type "*exists"
{"path": "*cgreq.Consumed", "type": "*difference", "value": "~*tmp.InputOutputSum;~*uch.PrevSum", "filters": ["*exists:~*uch.PrevSum:"]},
// create a variable with the value of the current sum whose path begins with *uch, which means that it will be saved in cache, ready to be used when determining the next difference
{"path": "*uch.PrevSum", "type": "*variable", "value": "~*tmp.InputOutputSum"}
],