Saving the amount of traffic passed through an interface in Bytes

I wanted to know if there is a way to find and save the amount of traffic passed through an interface, for instance the amount of data going out to and coming from the Internet to the local network (total upload/download). i have some ideas in mind for doing them but dont really know if they are applicable:

1- use packet sniffer and stream the data headers to a server for analysis (too complicated)
2- use a firewall filter rule or mangle and get the bytes counter periodically and add them up (dont know the commands for that )
3- there exist a simple tool or way or script that i am not aware of now.

please help me implement a method.

You can use SNMP to poll this number from an external computer and save it there.
Remember that the number resets to zero when the router is rebooted, and it can wrap-around when
there is so much traffic that it overflows (32-bit values). So your program has to handle those situations.

The Traffic Flow tool may help you

/ip traffic-flow

Use SNMP and any tool that allows for collecting such information.

Cacti
Observium
Mrtg
Munin
etc..