Charging configuration
This document describes the settings you can use to configure the charging sub-system in TPOSS. This sub-system is responsible for handling:
Tariffs configuration
TPOSS provisions a set of tariffs during the start-up. For each tariff, you have to configure a tenant using this configuration option:
It is possible to configure tariffs for multiple tenants:
With this configuration, a whole set of tariffs is provisioned for every specified tenant. For the example above, two online tariffs will be provisioned: online@tposs.cennso.net and online@additional.tenant.com.
Available tariffs
These are the tariffs that TPOSS provisions during the start-up:
To provision tariffs with a new tenant manually, use the following API:
Tip
For more information on how to run TPOSS commands, see the Troubleshooting guide.
Charging rules configuration
TPOSS specifies the list of charging rules and rating groups to allocate them when creating a user session and execute the charging procedures during the session's lifetime. Each rule has a name and a rating group identifier associated with it. To specify the list of rating groups with respective names to allocate charging rules and handle charging reports, use these configuration options:
In the example above, you may see the definition of the rating group with ID 1000 and with the associated Online charging rule. You can use any name instead of online in scg.{OPTION_NAME}.{RULE_NAME}, however, it must be consistent within the whole configuration for this rating group. Each rating group has a validity time - the period of time in seconds after which TPOSS expects to receive the charging report for the given rating group.
The scg.{RULE_NAME}.rating_groups_exclude_rules parameter specifies the list of charging rules that are excluded if the given RULE_NAME rule was allocated by TPOSS. The names listed in the scg.{RULE_NAME}.rating_groups_exclude_rules must be valid charging rules defined in the scg.adc_rules configuration.
Before allocating a charging rule for a user, TPOSS must know what conditions must be met. For this purpose, the scg.rating_groups_selectors.{RULE_NAME} configuration option exists. The rule selector is a string that lets you filter rules using one or more key-value pairs. Each condition within the selector follows the key = value format. You can combine multiple conditions using and or or. For example, the following charging rule selector describes the rule that will be applied if the charging rule handler online is applicable and the user has Called-Station-IDOpens in a new tab with the apn.1 prefix:
The possible keys are:
- handler - a handler name that checks if it is possible to allocate a given rating group for the given session
- called_station_id - a regular expression that is matched against
Called-Station-Idwithin a network session
Note
The handler key must be always the first condition in the expression.
The following handlers are supported:
b2binternet- a rule is allocated if a user has theB2BInternettariffonline- a rule is allocated if a user has theOnlinetariff and a valid balanceunlimited_streaming- a rule is allocated if a user has the unlimited streaming tariff optionwhitelist- a rule is allocated if the session has unknown IMEISV and the whitelist functionality is enabled
The size of quota allocated for a user usually depends on the tariff, balance, and the handler of the rule. If the selector is not specified for the given charging rule, define a pre-allocated quota for such rule:
Note
Rules without a selector are always allocated to a user, unless they are specified in the scg.rating_groups_exclude_rules for rules that are already allocated.
Here is the example of the default TPOSS configuration with the description of all defined charging rules, rating groups, and their behaviour:
You can disable the unlimited_streaming and unlimited_streaming_pd charging rules.
To do so, use this configuration option:
To configure the traffic quota that is allocated for the sessions with the B2BInternet charging rule, use this configuration option:
Note
The scg.b2b_internet_quota configuration option is deprecated and will be removed in the next releases. Instead, specify the scg.rating_groups_quotas.b2binternet = {QUOTA} option with the scg.rating_groups_selector.b2binternet = "handler = b2binternet" selector.
Charging Data Records configuration
When the service session is terminated or a balance is exhausted by validity time or by quota, TPOSS creates a Charging Data Record (CDR). TPOSS may write CDRs to multiple backends. The following backends are supported:
Read the sections below to learn how to enable (or disable) and configure these backends.
Database backend
You can configure TPOSS to generate CDRs to the MySQL database backend using these configuration options:
The configuration option cdr.controller.database.enabled enables storing the generated charging data records in the MySQL database.
The configuration option cdr.controller.database.ignore contains a list of selectors that specify criteria for which CDRs should not be generated. If a selector is matched for the given session, the charging data records are not generated. The selectors are in the form of key:value. The currently supported key is only Called-Station-Id. The value can be any regular expression. In the example above, the CDRs are not created for the sessions from APNs, such as apn1.example-2.com, apn2.example-3.com, and so on.
Tip
Partitioning is an effective way to manage big write-only tables with historic data. That's why it is recommended to enable CDR table partitioning using the cdr.controller.database.partitions_enabled option.
If the partitioning is enabled, TPOSS provisions special stored proceduresOpens in a new tab to create, maintain active partitions, and delete the old ones. In a new TPOSS deployment, the configuration option cdr.controller.database.initial_partitions_amount specifies the initial number of partitions to create.
The cdr.controller.database.partitions_duration configuration option specifies how long the given partition should be considered active and may be used to insert the new charging data records. The cdr.controller.database.cdr_cleanup_period configuration option specifies a time unit after which all the partitions which were created earlier than this time are dropped. The definitions of the time periods specified in the cdr.controller.database.partitions_duration and cdr.controller.database.cdr_cleanup_period options consist of a positive integer and a time unit, for example: 14-days, month, 2-minutes. The supported time units are:
- second(s)
- minute(s)
- hour(s)
- day(s)
- week(s)
- month(s)
- year(s)
As soon as there is only a single active partition remaining, the database triggers the stored procedure to create new partitions for rotation. The cdr.controller.database.new_partitions_amount configuration option specifies the number of new partitions to create.
The clean_up_partitions_at parameter is an optional configuration option that may contain a string value in the "HH:MM" format. If the configuration value is not empty, TPOSS provisions an event for the deletion of outdated CDR partitions, which should be triggered once a day at the specified time. If this configuration option is set to an empty string (""), the event to delete the outdated partitions is triggered every seven minutes. The time zone of the given time depends on the time zone configuredOpens in a new tab at the database server.
Note
You should run the partition deletion during a less busy time not to impact other database queries.
If the deletion of partitions that is triggered once per-day failed, or if you want to trigger it during maintenance time, you can do it manually with the MySQL client by calling this procedure:
The procedure above drops all the partitions which are older than 14 days. This procedure accepts two arguments:
- The first argument specifies the number of units after which a partition is considered as outdated.
- The second argument specifies the time unit.
Tip
If the creation of new partitions failed, check the Repair partitions in the CDR table troubleshooting guide.
If partitioning is disabled, the special process watches for a CDR table and deletes CDRs that are outdated. The following options control the behaviour of this process:
- cdr.controller.database.cdr_cleanup_limit - limit of CDRs to remove at once. The supported values are any positive integer values or the string
all. - cdr.controller.database.cdr_cleanup_query_timeout - timeout in milliseconds that specifies the max time of the query to delete outdated CDRs.
- cdr.controller.database.watcher_timeout - timeout in milliseconds that specifies how often to check a CDR table for outdated CDRs
File backend
You can configure TPOSS to generate CDRs to the file backend using these configuration options:
The configuration option cdr.controller.file.enabled enables storing the generated charging data records in CSV files.
The cdr.controller.file.ignore configuration option contains a list of selectors that specify criteria for which CDRs should not be generated. It works the same as the cdr.controller.database.ignore option in the database controller.
The other configuration options specify where to store CSV files on a disk and how to rotate them. The cdr.controller.file.dir configuration option specifies the path to the directory where CDRs are written. The cdr.controller.file.time_window specifies time in seconds for the charging data record files rotation. The cdr.controller.file.max_count configuration option specifies the maximum number of charging data records in one file.
The cdr.controller.file.file_name_format configuration option specifies the format of the CSV file names. The format is a string that may contain placeholders that are replaced in the actual file name on disk. Based on the example above, the resulting file name may look like:
The following placeholders are supported:
batch_id- UUID identifier for the current TPOSS instance. Changed after each TPOSS restart.file_counter- Number of files created by the given TPOSS instance.file_id- UUID identifier of the CDR file.start_at- Time when the CDR file was created.end_at- Time when the CDR file was closed.first_at- Time when the first CDR was written to the file.last_at- Time when the last CDR was written to the file.counter- Number of CDRs written to the file.sha- SHA1 hashOpens in a new tab of the CDR file content.sha256- SHA256 hashOpens in a new tab of the CDR file content.sha512- SHA512 hashOpens in a new tab of the CDR file content.md5- MD5Opens in a new tab of the CDR file content.
The start_at, end_at, first_at, and last_at parameters must provide information about the time format. The format must be passed along with the parameter name, split by the : symbol. For example - start_at:ISO8601:UTC. The following formats are supported:
ISO8601- UTC date and time in theISO8601format. For example -2025-06-20T12:11:12.ISO8601:UTC- UTC date and time in theISO8601format with suffixZ. For example -2025-06-20T12:11:12Z.ISO8601:STRIPPED- UTC date and time in theISO8601format without-and:symbols. For example -20250620T121229.ISO8601:UTC:STRIPPED- UTC date and time in theISO8601format with suffixZand without-and:symbols. For example -20250620T121229Z.
To write CDRs on a disk, you must specify a persistent volumeOpens in a new tab:
Note
To have access to the file-based CDRs, TPOSS provides an SFTP service that you must configure. Read the next section to learn more.
SFTP settings
You can enable an SFTP container so that CDRs can be fetched from an external system for further CDR processing:
To access an SFTP server, you must first configure credentials for the user. The TPOSS SFTP server provides support only for a single user with the username sftp. To specify the password, use the sftp.sftpConfig.password configuration option. The format of the password depends on the value of sftp.sftpConfig.passwordFormat. The following formats are supported:
plaincrypt
If sftp.sftpConfig.passwordFormat is set to plain, sftp.sftpConfig.password must contain a plaintext password. In this case, the password is hashed by the init container specified in the sftp.initImage option.
Important
You can use any image for the SFTP init container, but it must contain the openssl CLI.
If sftp.sftpConfig.passswordFormat is set to crypt, sftp.sftpConfig.password must contain a password hashed with a crypt algorithm. For example, the value of the key-value pair sftpConfig.password = "$1$RsBlW1hk$/ISHFEK0yrEX8M7x9.lbB1" from the example above was obtained by running this command:
For more information about the SFTP service configuration, see the Kubernetes serviceOpens in a new tab documentation.