> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tsr/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/tsr/latest/configuration/flowusage-biflow.md).

# Set up TSR Sink for FlowUsage biflow IPFIX messages

Traffic Stream Reporter (TSR) that handles FlowUsage biflow IPFIX messages, stores information about network flows.
It stores how many bytes and packets were sent to and from an external IP address.
Additionally, the virtual routing and forwarding (VRF) name, interface name, and observation domain name are stored.

## Prerequisites

- [Kubernetes 1.18](https://kubernetes.io/docs/tasks/tools/) or newer
- [Helm client](https://helm.sh/docs/intro/install/) 3.9.2 or newer
- MySQL database

## Steps

1. Create a namespace for your TSR installation:

   ```bash
   kubectl create namespace tsr
   ```

2. Create a TSR Sink configuration file that saves information from the IPFIX packages into your deployed MySQL database. The information is stored in the `egress_$day` and `ingress_$day` tables. You can adjust the **ueNet** parameter to classify the IPFIX message in egress or ingress so that it can be stored in the corresponding database tables:

   ```yaml
   db:
      host: db
      port: 3306
      user: ipfix
      pass: ipfix
      db: tsr
      persist:
         duration: 5s
   
   ipfix:
      debug: true
      type: flowUsage
      aggregated: true # that is also the default value
      biFlow: true # that is also the default value
   ```

3. Install TSR Sink on the cluster:

   ```bash
   helm install tsr-sink {REPOSITORY_NAME}/tsr-sink -f {FILENAME}.yaml --namespace tsr
   ```

4. Fetch all flowUsage data from the database with the SQL statement below. The table name is `traffic_YEAR_MONTH_DAY`.

   ```sql
   SELECT
   ip_dst AS dest,
   vrfName,
   interfaceName,
   observationDomainName,
   toBytes,
   fromBytes
   FROM traffic_2024_03_01;
   ```
