Persistence is fully documented here with examples. Choose a database to store the data. You probably don’t want to use MapDB (only stored the latest value) or rrd4j (requires an every minute strategy). InfluxDB is my perferred DB. If you are running openHABian there is an option in openHABian-config to install and configure it.
The documentation for the add-on for what ever database you choose will have further examples for how to write the .persist file.
InfluxDB+Grafana persistence and graphing has a good tutorial for installing and configuring InfluxDB.