Hello, i hope you are doing fine, i need some help please. I am trying to export some data using the EES, i want to export the data in JSON format, so i am using " "type": "*http_json_map" ". I want to get the NumberOfEvents, TotalDuration, TotalCost( will call them stats) of the events(CDRs) but it does not give me a correct value, it just gives me the stats of the last CDR ( NumberOfEvents = 1,
TotalDuration = Usage,
TotalCost= cost of the call). However the same functionality works when i export the EES in CSV format. here is an example, and the config :
here is the CONFIG.JSON :
{
"general": {
"log_level": 15,
"node_id": "DIGIVOIP BILLING SYSTEM",
"default_tenant": "DIGIVOIP",
"poster_attempts": 1
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
"http_tls": ":2280"
},
"tls": {
"server_certificate": "/etc/cgrates/ssl/fullchain.pem",
"server_key": "/etc/cgrates/ssl/privkey.pem",
"client_certificate" : "",
"client_key":"",
"ca_certificate":""
,
"server_policy":0,
"server_name":"
cg.digivoip.fr"
},
"stor_db": {
"db_password": "CGRateS.org"
},
"schedulers": {
"enabled": true,
"cdrs_conns": ["*localhost"]
},
"rals": {
"enabled": true,
"thresholds_conns": ["*localhost"],
"stats_conns": ["*localhost"]
},
"cdrs": {
"enabled": true,
"stats_conns": ["*localhost"],
"chargers_conns": ["*localhost"],
"attributes_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"sessions_cost_retries": 5
},
"chargers": {
"enabled": true,
"attributes_conns": ["*localhost"]
},
"sessions": {
"enabled": true,
"rals_conns": ["*localhost"],
"cdrs_conns": ["*localhost"],
"resources_conns": ["*localhost"],
"routes_conns": ["*localhost"],
"attributes_conns": ["*localhost"],
"stats_conns": ["*localhost"],
"thresholds_conns": ["*localhost"],
"chargers_conns": ["*localhost"],
"debit_interval": "5s",
"channel_sync_interval": "5s"
},
"freeswitch_agent": {
"enabled": true,
"event_socket_conns": [
{"address": "
172.16.2.101:8021", "password": "ClueCon", "reconnects": -1, "alias": "
fs1.digivoip.fr"},
{"address": "
172.16.2.102:8021", "password": "ClueCon", "reconnects": -1, "alias": "
fs2.digivoip.fr"}
],
"sessions_conns": ["*birpc_internal"],
"extra_fields": [
"~*req.Caller-Caller-ID-Name",
"~*req.Caller-Callee-ID-Number",
"~*req.variable_caller_id_name",
"~*req.variable_caller_id_number",
"~*req.Caller-Channel-Hangup-Time",
"~*req.Call-Direction"
],
"create_cdr": true
},
"filters": {
"enabled": true,
"apiers_conns": ["*localhost"],
"ees_conns": ["*localhost"]
},
"attributes": {
"enabled": true,
"stats_conns": ["*localhost"],
"resources_conns": ["*localhost"],
"apiers_conns": ["*localhost"],
"ees_conns": ["*localhost"]
},
"resources": {
"enabled": true,
"string_indexed_fields": ["*req.Account"]
},
"stats": {
"enabled": true,
"store_interval": "0",
"indexed_selects": false
},
"thresholds": {
"enabled": true,
"string_indexed_fields": ["*req.Account"]
},
"routes": {
"enabled": true,
"resources_conns": ["*localhost"],
"stats_conns": ["*localhost"],
"rals_conns": ["*localhost"],
"string_indexed_fields": ["*req.Account"]
},
"apiers": {
"enabled": true,
"scheduler_conns": ["*localhost"],
"ees_conns": ["*localhost"]
},
"ees": {
"enabled": true,
"attributes_conns": ["*localhost"],
"filters_conns": ["*localhost"],
"cache": {
"*file_csv": {
"limit": -1,
"ttl": "1s",
"static_ttl": false
}
},
"exporters": [
{
"id": "HTTPJsonMapExporter",
"type": "*http_json_map",
"filters": [],
"synchronous": true,
"export_path": "
http://172.16.2.110/event_json_map_http",
"fields": [
{"tag": "Number", "path": "*exp.Number", "type": "*variable", "value": "~*dc.NumberOfEvents"},
{"tag": "CGRID", "path": "*exp.CGRID", "type": "*variable", "value": "~*req.CGRID"},
{"tag": "RunID", "path": "*exp.RunID", "type": "*variable", "value": "~*req.RunID"},
{"tag": "ToR", "path": "*exp.ToR", "type": "*variable", "value": "~*req.ToR"},
{"tag": "DestinationID", "path": "*exp.Destination", "type": "*variable", "value": "~*ec.Charges[0].Rating.RatingFilter.DestinationID"},
{"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value": "~*req.RequestType"},
{"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*req.Tenant"},
{"tag": "Category", "path": "*exp.Category", "type": "*variable", "value": "~*req.Category"},
{"tag": "Account", "path": "*exp.Account", "type": "*variable", "value": "~*req.Account"},
{"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value": "~*req.Subject"},
{"tag": "Destination", "path": "*exp.Destination", "type": "*variable", "value": "~*req.Destination"},
{"tag": "SetupTime", "path": "*exp.SetupTime", "type": "*variable", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "Usage", "path": "*exp.Usage", "type": "*variable", "value": "~*req.Usage"},
{"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost{*round:4}"},
{"tag": "RatingPlan", "path": "*exp.RatingPlan", "type": "*variable", "value": "~*ec.Charges[0].Rating.RatingFilter.RatingPlanID"},
{"tag": "RatingPlanSubject", "path": "*exp.RatingPlanSubject", "type": "*variable", "value": "~*ec.Charges[0].Rating.RatingFilter.Subject"},
{"tag": "NumberOfEvents", "path": "*trl.NumberOfEvents", "type": "*variable", "value": "~*dc.NumberOfEvents"},
{"tag": "TotalDuration", "path": "*trl.TotalDuration", "type": "*variable", "value": "~*dc.TotalDuration"},
{"tag": "TotalCost", "path": "*trl.TotalCost", "type": "*variable", "value": "~*dc.TotalCost{*round:4}"}
]
},
{
"id": "CSVExporter",
"type": "*file_csv",
"filters": [],
"synchronous": true,
"export_path": "/home/export",
"opts": {
"csvFileName": "CSVExporter_works.csv",
"csvAppend": false,
"csvFieldSeparator": ","
},
"fields": [
{"tag": "Number", "path": "*exp.Number", "type": "*variable", "value": "~*dc.NumberOfEvents"},
{"tag": "CGRID", "path": "*exp.CGRID", "type": "*variable", "value": "~*req.CGRID"},
{"tag": "RunID", "path": "*exp.RunID", "type": "*variable", "value": "~*req.RunID"},
{"tag": "ToR", "path": "*exp.ToR", "type": "*variable", "value": "~*req.ToR"},
{"tag": "DestinationID", "path": "*exp.Destination", "type": "*variable", "value": "~*ec.Charges[0].Rating.RatingFilter.DestinationID"},
{"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value": "~*req.RequestType"},
{"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*req.Tenant"},
{"tag": "Category", "path": "*exp.Category", "type": "*variable", "value": "~*req.Category"},
{"tag": "Account", "path": "*exp.Account", "type": "*variable", "value": "~*req.Account"},
{"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value": "~*req.Subject"},
{"tag": "Destination", "path": "*exp.Destination", "type": "*variable", "value": "~*req.Destination"},
{"tag": "SetupTime", "path": "*exp.SetupTime", "type": "*variable", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "Usage", "path": "*exp.Usage", "type": "*variable", "value": "~*req.Usage"},
{"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost{*round:4}"},
{"tag": "RatingPlan", "path": "*exp.RatingPlan", "type": "*variable", "value": "~*ec.Charges[0].Rating.RatingFilter.RatingPlanID"},
{"tag": "RatingPlanSubject", "path": "*exp.RatingPlanSubject", "type": "*variable", "value": "~*ec.Charges[0].Rating.RatingFilter.Subject"},
{"tag": "NumberOfEvents", "path": "*trl.NumberOfEvents", "type": "*variable", "value": "~*dc.NumberOfEvents"},
{"tag": "TotalDuration", "path": "*trl.TotalDuration", "type": "*variable", "value": "~*dc.TotalDuration"},
{"tag": "TotalCost", "path": "*trl.TotalCost", "type": "*variable", "value": "~*dc.TotalCost{*round:4}"}
]
},
{
"id": "HTTPPostExporter",
"type": "*http_post",
"export_path": "
http://172.16.2.110/event_json_map_http",
"flags": ["*attributes"],
"attribute_context": "customContext",
"attempts": 1,
"fields":[
]
}
]
}
}
here is the export functionality for the JSON Export:
{
"method": "APIerSv1.ExportCDRs",
"params": [
{
"ExporterIDs": ["HTTPJsonMapExporter"],
"Verbose": true,
"SetupTimeStart": "",
"SetupTimeEnd": "",
"Destinations": [],
"Accounts": ["OPTIMIS"],
"Subjects": [],
"Tenants": ["DIGIVOIP"]
}
]
}
here is the result of the postman(verbose : true ):
{
"id": null,
"result": {
"HTTPJsonMapExporter": {
"FirstEventATime": "2025-07-01T08:00:00+01:00",
"FirstExpOrderID": 359,
"LastEventATime": "2025-07-01T08:00:00+01:00",
"LastExpOrderID": 359,
"NegativeExports": [],
"NumberOfEvents": 1,
"PositiveExports": [
"022d199"
],
"TimeNow": "2025-07-01T17:45:00.19511431+01:00",
"TotalCost": 1
}
},
"error": null
}
here is the JSON file( i deleted some lines) :
{"Account":"OPTIMIS","AnswerTime":"0001-01-01T00:00:00Z","CGRID":"010ccc0fa3033d03b9610083d3ce4deb66d49c65","Category":"CALL-OUT","Cost":"0","Destination":"33184140117","Number":"1","RequestType":"*prepaid","RunID":"*default","SetupTime":"2025-06-15T10:54:01+01:00","Subject":"FRANCE_STANDARD_PACK1","Tenant":"DIGIVOIP","ToR":"*voice","Usage":"0"}
{"Account":"OPTIMIS","AnswerTime":"2025-06-15T10:59:54+01:00","CGRID":"aa9e6dfd10e4405c19ce4a0b1767091230affb9a","Category":"SUPPLIER-OUT","Cost":"0.0007","Destination":"33184140117","Number":"1","RatingPlan":"SUPPLIER_OUT_1","RatingPlanSubject":"*out:DIGIVOIP:SUPPLIER-OUT:*any","RequestType":"*rated","RunID":"SupplierCharger-OUT","SetupTime":"2025-06-15T10:59:45+01:00","Subject":"FRANCE_STANDARD_PACK1","Tenant":"DIGIVOIP","ToR":"*voice","Usage":"12000000000"}
{"Account":"OPTIMIS","AnswerTime":"2025-06-15T10:59:54+01:00","CGRID":"aa9e6dfd10e4405c19ce4a0b1767091230affb9a","Category":"CALL-OUT","Cost":"0.2","Destination":"33184140117","Number":"1","RatingPlan":"FRANCE_STANDARD","RatingPlanSubject":"*out:DIGIVOIP:CALL-OUT:FRANCE_STANDARD_PACK1","RequestType":"*prepaid","RunID":"*default","SetupTime":"2025-06-15T10:59:45+01:00","Subject":"FRANCE_STANDARD_PACK1","Tenant":"DIGIVOIP","ToR":"*voice","Usage":"12000000000"}
{"Account":"OPTIMIS","AnswerTime":"2025-06-15T11:25:09+01:00","CGRID":"43ebf61b24f233864eddd7670b8afbf3bb45783d","Category":"SUPPLIER-OUT","Cost":"0.001","Destination":"33184140117","Number":"1","RatingPlan":"SUPPLIER_OUT_1","RatingPlanSubject":"*out:DIGIVOIP:SUPPLIER-OUT:*any","RequestType":"*rated","RunID":"SupplierCharger-OUT","SetupTime":"2025-06-15T11:25:00+01:00","Subject":"FRANCE_STANDARD_PACK1","Tenant":"DIGIVOIP","ToR":"*voice","Usage":"17000000000"}
{"Account":"OPTIMIS","AnswerTime":"0001-01-01T00:00:00Z","CGRID":"f5d9de394c9941a53552cdbb8c17853b0583b690","Category":"CALL-OUT","Cost":"0","Destination":"33184140117","Number":"1","RequestType":"*prepaid","RunID":"*default","SetupTime":"2025-06-27T08:47:22+01:00","Subject":"FRANCE_STANDARD_PACK1","Tenant":"DIGIVOIP","ToR":"*voice","Usage":"0"}
{"Account":"OPTIMIS","AnswerTime":"2025-07-01T08:00:00+01:00","CGRID":"f4521dd33de3c3084906ee9dfb0e5d177a12a1d2","Category":"call","Cost":"1","Destination":"","Number":"1","RequestType":"*none","RunID":"*debit","SetupTime":"2025-07-01T08:00:00+01:00","Subject":"OPTIMIS","Tenant":"DIGIVOIP","ToR":"*monetary","Usage":"1"}