> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/cdf/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/cdf/latest/releases/migration_from_cdf3_to_cdf4.md).

# Migration guide from CDF&nbsp;3 to CDF&nbsp;4

Charging Data Function (CDF) 4.0 release introduces new configuration options for NATS storage capabilities and removes options that are no longer used. The changes to the Helm chart are not backwards compatible.

Metrics are also updated respectively.

## Migration steps

Follow these steps to migrate from CDF&nbsp;3 to CDF&nbsp;4:

1. Install the required number of CDF&nbsp;4 receiver instances to separate concerns (for example, per SMC or APN).
1. Configure all SMC instances to use receivers based on CDF&nbsp;4. Ensure no active CDF&nbsp;3 receiver is receiving charging events.
1. Monitor CDF&nbsp;3 sender to ensure it transmitted all pending CDRs.
1. Retrieve persisted CDF&nbsp;3 sender values.

   CDF 4 uses NATS to store operational values like **gtp_sequence_number**, which is needed to send CDRs to CGF. To avoid conflicts during migration, ensure CDF&nbsp;4 starts with a sequence number higher than the last one used by CDF&nbsp;3. If CDF&nbsp;4 reuses already-used sequence number, CGF will reject or drop the CDRs. To get the last used sequence number, log in to CDF 3 sender and run:
   ```bash
   /opt/ercdf/bin/ercdf eval '{ok,B}=file:read_file("/data/gtp_sequence_number"),erlang:binary_to_term(B).'
   ```
1. Disable CDF&nbsp;3 sender.
1. Add persisted CDF&nbsp;3 sender values to NATS.

   CDF 4 stores **gtp_sequence_number** in the NATS key-value store. Increase the value of the retrieved sequence number from step 4 and add it to the NATS key-value store. For example, to store the sequence number `123` in the NATS key-value bucket named **cdf_bucket** with the key **gtp_sequence_number**, use the following command:

   ```bash
   nats kv create cdf_bucket gtp_sequence_number 123
   ```
1. Deploy and activate CDF&nbsp;4 sender.

## New configuration options

These configuration options are added to the CDF Helm chart:

- image.repository_receiver
- image.repository_sender
- receiver.nodeID
- sender.cdr_limit_per_cgf
- nats
- nats_create

For more information about these configuration parameters, read the [CDF chart configuration](https://docs.cennso.com/components/cdf/latest/technical-reference/chart-config.md) document.

## Removed configuration options

These configuration options are removed from the CDF Helm chart:

- image.repository
- receiver.directory
- receiver.waitS3
- sender.accumulateMax
- sender.cdrMax
- sender.cdrTime
- sender.directories
- sender.transportOptions.echo
- sender.waitS3
- storage

## New metrics

These new metrics are added to CDF:

- ercdf_cdr_from_nats_total
- ercdf_nats_error_total

For more information, read the [Metrics](https://docs.cennso.com/components/cdf/latest/observability/metrics.md) document.

## Removed metrics

These metrics are removed from CDF:

- ercdf_cdr_deleted_on_disk_total
- ercdf_cdr_from_s3_deleted_total
- ercdf_cdr_from_s3_total
- ercdf_cdr_to_s3_deleted_total
- ercdf_cdr_to_s3_total
