Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to export the used balance's Account remining Value

89 views
Skip to first unread message

Sami Ali

unread,
Mar 15, 2025, 10:06:18 PMMar 15
to CGRateS

Kindly, I need help guiding with a minor issue:
All are working fine that EES is exporting all fields as below except this as I need to export the value of the used balance(to let the subscribers to get their remaining balance after each call, so I tried many criteries to get the value as below but I didn't get at all the "Value" part nor even anything pointing to it :
{"tag": "Value","path": "*exp.Value","type": "*variable","value": "~*req.CostDetails.AccountSummary.BalanceSummaries[0].Value"}


My config as below:
"ees": {
"enabled": true,
"attributes_conns":["*internal"],
"exporters": [
{
"id": "sms_balance_notification",
"type": "*http_post",
"synchronous": true,
"field_separator": ",",
"flags": ["*cdrs","*log"],
//"flags": ["*terminate"],
// "flags": ["*attributes"],

"attempts": 1,
"fields": [
{"tag": "from","path": "*exp.from","type": "*variable","value": "smsc" // Sender number (fixed)},
{ "tag": "to","path": "*exp.to", "type": "*variable","value": "~*req.Account" // Recipient number (dynamic, from the CDR)},
{"tag": "Usage", "path": "*exp.Usage", "type": "*variable", "value": "~*req.Usage"},
{"tag": "Destination", "path": "*exp.Destination", "type": "*variable", "value": "~*req.Destination"},
{"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost{*round:2}","width": 9, "padding": "*zeroleft"},
{"tag": "Value","path": "*exp.Value","type": "*variable","value": "~*req.CostDetails.AccountSummary.BalanceSummaries[0].Value"}
],
"opts": {
"httpParameters": {
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"body": {
"from": "~*exp.from",
"to": "~*exp.to",
"Cost": "~*exp.Cost",
"Usage": "~*exp.Usage",
"Value":"*exp.Value",
"Destination":"*exp.Destination"
}
}
}
},

Attached also the ngrep..

Regards,
Sami
ngrep

Sami Ali

unread,
Mar 17, 2025, 8:24:19 PMMar 17
to CGRateS
Hi Cgrates Team,

I am sorry that i am already  getting the value but wondering why i cant noticed that ,my bad :)

its there :
Cost=0000001.4&Destination=bob&Usage=12000000000&Value=45.8&from=smsc&to=alice.

So i have observed another issue that i did only one call but i got the EES exported two times with different values,could you please check it and advice.

Cost=0000001.4&Destination=bob&Usage=12000000000&Value=45.8&from=smsc&to=alice

and :
Cost=0000001.4&Destination=bob&Usage=12000000000&Value=44.4&from=smsc&to=alice


Armir Veliaj

unread,
Mar 18, 2025, 6:49:02 AMMar 18
to CGRateS
Hi Sam,

By looking at the ngrep, it seems that it is exported twice because EeSv1.ProcessEvent was called twice during the ProcessCDR of two different sessions.
The way you are extracting the balance value from AccountSummary works fine, but if it's easier for you, you can also retrieve it by balance name rather than index, like this example:
{"tag": "BalanceValue", "path": "*exp.BalanceValue", "type": "variable", "value": "~req.CostDetails.AccountSummary.BalanceSummaries.BALANCE_ID.Value"}.

Thanks,
Armir

Sami Ali

unread,
Mar 18, 2025, 11:50:31 PMMar 18
to cgr...@googlegroups.com
Hi Armir,

Thank you so much for your support.
I can't find that EeSv1.ProcessEvent was called twice during the ProcessCDR of two different sessions.
I am sending you my config via your email so you can point to me where that duplicate is, as I need the export to be called only once after each call(that is all).

In addition, thank you for your hint about using a direct balance_id instead of indexing :

Is there any way to treat the below to point automatically to the used balance_id and get its value? For example, if I am making a voice call and the deduction was from DEFUALT_ACNT, it shall export the value of this account's balance, and if the deduction was from Data_account, I should get the value of the balance_id=Data_account, etc.


{"tag": "BalanceValue", "path": "*exp.BalanceValue", "type": "variable", "value": "~req.CostDetails.AccountSummary.BalanceSummaries.BALANCE_ID.Value"}


--
You received this message because you are subscribed to the Google Groups "CGRateS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cgrates+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cgrates/204a74d1-46b7-4192-8208-04982160c6e0n%40googlegroups.com.

Armir Veliaj

unread,
Mar 27, 2025, 3:59:06 AMMar 27
to CGRateS
Hi Sam,

I checked the configurations and templates you sent, and they appear correct without duplicates and I suspect you are sending two separate Diameter requests. Please provide your Diameter traffic via tcpdump to help us verify this.

As for retrieving the balance value without specifying the balance ID, you can get it by using a different path as in this sample : ~req.CostDetails.Charges[0].Increments[i].Accounting.Balance.Value .

Thanks,
Armir
Reply all
Reply to author
Forward
0 new messages