Dad, Software Nerd, Human

Fossil

https://github.com/dburkart/fossil

The fossil database is a simple and expressive time-series database that was built on a lark with Gideon Williams.

The basic idea is a simple time-series database à la SQLite. It should be simple to set up, simple to use, and powerful enough to be useful.

It was a lot of fun to build, and I think it's also fun to use. Here is an example where I set up a cron job to pipe load averages into the database. The cron job has been running for weeks now. Here are some examples:

Querying the last 10 minutes of load averages

> query all in /stats/load since ~now - 10 * @minute
+-------------------------------------+-------------------------+------------+------------------------------+
|                TIME                 |          TOPIC          |   SCHEMA   |             DATA             |
+-------------------------------------+-------------------------+------------+------------------------------+
| 2023-03-14T21:58:00.115234274-07:00 | /stats/load/iotas.local | [3]float64 | 0.430000, 0.340000, 0.280000 |
| 2023-03-14T21:59:00.099006098-07:00 | /stats/load/iotas.local | [3]float64 | 0.560000, 0.390000, 0.290000 |
| 2023-03-14T22:00:00.118148005-07:00 | /stats/load/iotas.local | [3]float64 | 0.430000, 0.380000, 0.290000 |
| 2023-03-14T22:01:00.112568466-07:00 | /stats/load/iotas.local | [3]float64 | 0.390000, 0.370000, 0.290000 |
| 2023-03-14T22:02:00.108439735-07:00 | /stats/load/iotas.local | [3]float64 | 0.210000, 0.320000, 0.280000 |
| 2023-03-14T22:03:00.105821792-07:00 | /stats/load/iotas.local | [3]float64 | 0.240000, 0.300000, 0.270000 |
| 2023-03-14T22:04:00.11002568-07:00  | /stats/load/iotas.local | [3]float64 | 0.320000, 0.300000, 0.270000 |
| 2023-03-14T22:05:00.249171874-07:00 | /stats/load/iotas.local | [3]float64 | 0.160000, 0.260000, 0.250000 |
| 2023-03-14T22:06:00.065187333-07:00 | /stats/load/iotas.local | [3]float64 | 0.270000, 0.270000, 0.250000 |
| 2023-03-14T22:07:00.099360557-07:00 | /stats/load/iotas.local | [3]float64 | 0.240000, 0.260000, 0.250000 |
+-------------------------------------+-------------------------+------------+------------------------------+

Counting the number of load averages in the last day

> query all in /stats/load since ~now - @day | map -> 1 | reduce a, b -> a + b
+-------------------------------------+-------+--------+------+
|                TIME                 | TOPIC | SCHEMA | DATA |
+-------------------------------------+-------+--------+------+
| 2023-03-14T22:23:00.110706028-07:00 | N/A   | int64  | 1440 |
+-------------------------------------+-------+--------+------+

Calculate the average load over the last day

> query all in /stats/load since ~now - @day | map x -> x[0], 1 | reduce a, b -> a[0] + b[0], a[1] + b[1] |
  map x -> x[0] / x[1]
+-------------------------------------+-------+---------+----------+
|                TIME                 | TOPIC | SCHEMA  |   DATA   |
+-------------------------------------+-------+---------+----------+
| 2023-03-14T22:25:00.052214871-07:00 | N/A   | float64 | 0.270882 |
+-------------------------------------+-------+---------+----------+