Export CDRs to flat files (Thrift)
Reading CDRs from the switch’s database puts load on it and ties your reporting to its retention. With the Thrift export, the switch also writes every call, CDR and balance update to binary files that rotate on a schedule. Your billing, data warehouse or fraud system collects the files and parses them, and the database can keep CDRs for only a few days.
How it works
Section titled “How it works”- The switch processes and bills calls as usual.
- When a call ends, the switch appends its records to the current file of each record type, in Apache Thrift binary format.
- On every rotation the current files are closed and new ones are started. The closed files carry the rotation time in their name.
- Your system collects the closed files, or receives them on an SFTP server, and parses them with Thrift.
- The switch deletes old files on its own, so the disk does not fill up.
The files of environment N are in /var/envN/upload/cdrs/thrift/. Every record carries i_call, which links the records of one call across files.
These files are always written:
| File | Records |
|---|---|
calls-thrift.bin |
One per call: Call-ID, CLI, CLD, setup time, routing group. The key for the other files |
cdrs-thrift.bin |
Account CDRs: result, duration, billed duration, cost, prices, remote IP, user agent |
cdrs_connections-thrift.bin |
Vendor CDRs: one per attempt to a vendor connection, with its cost and result |
balance_updates-thrift.bin |
Balance changes of the accounts, customers and vendors in the call |
These are written when the feature is in use:
| File | Records |
|---|---|
cdrs_customers-thrift.bin |
Customer CDRs |
cdrs_dids-thrift.bin |
DID CDRs |
cdrs_customers_dids-thrift.bin |
CDRs of DIDs delegated to customers |
cdrs_connections_dids-thrift.bin |
Vendor CDRs of DIDs, when the DID’s authentication rule has a buying DID charging group |
commissions-thrift.bin |
Commissions paid for the call |
calls_sdp-thrift.bin |
SDP bodies of the call, when SDP recording is on for the environment |
surcharges-thrift.bin |
Extra charges applied to the call |
Times are Unix timestamps in UTC.
Turn it on
Section titled “Turn it on”Ask FlySIP support to enable the Thrift export for an environment and to set:
- the rotation period, for example every 60 minutes;
- how long closed files stay on the switch;
- optionally, an SFTP server that receives the files.
Support switches on the system configuration key system/cdrs/export/thrift/enabled of the environment. You can read it with getSystemConfig.
Read a file on the switch
Section titled “Read a file on the switch”To check what the switch writes, print a file with the parser that ships with it:
sudo /home/ssp/scripts/support_tools/thrift_parser.py /var/env1/upload/cdrs/thrift/cdrs-thrift.binCdrs(i_cdr=2554692, i_account=34, result=0, cost=0.3603, duration=2.18, billed_duration=2.0, connect_time=1672226855, disconnect_time=1672226857, cld_in='12064248284', prefix='1', price_1=0.0063, price_n=0.0043, remote_ip='192.0.2.34', i_call=935442, ...)The parser takes several files or a pattern, for example …/thrift/*-thrift.bin*. For your own parser, ask FlySIP support for the Thrift definition file of your release.