Tutorial

starting server

docker run -p 8000:8000 -it jptmoore/nibbledb --enable-tls

adding data

Values are floats which can optionally be tagged with extra information. If no timestamp is provided it will be automatically generated as an epoch in millisecond precision.

curl -k --request POST --data '[{"value": 1}, {"value": 2}, {"value": 3}, {"value": 4}, {"value": 5}]' https://localhost:8000/ts/foo
curl -k --request POST --data '[{"value": 10}, {"value": 20}, {"value": 30}, {"value": 40}, {"value": 50}]' https://localhost:8000/ts/bar
curl -k --request POST --data '[{"colour":"red", "value": 1}, {"colour":"blue", "value": 2}, {"colour":"green", "value": 3}, {"colour":"red", "value": 4}, {"colour":"red", "value": 5}]' https://localhost:8000/ts/baz
curl -k --request POST --data '[{"timestamp":1, "value": 100}, {"timestamp":2, "value": 200}, {"timestamp":3, "value": 300}, {"timestamp":4, "value": 400}, {"timestamp":5, "value": 500}]' https://localhost:8000/ts/boz

retrieving data

A typical request to obtain the last n values

curl -k https://localhost:8000/ts/foo/last/3
[{"timestamp":1545232878575320,"data":{"value":5}},{"timestamp":1545232878575311,"data":{"value":4}},{"timestamp":1545232878575302,"data":{"value":3}}]

Finding the combined length of two time series

curl -k https://localhost:8000/ts/foo,bar/length
{"length":10}

A range query from a specific point in time

curl -k https://localhost:8000/ts/boz/since/4
[{"timestamp":5,"data":{"value":500}},{"timestamp":4,"data":{"value":400}}]

A query which filters the result based on matching tagged values and then applies an aggregation function

curl -k https://localhost:8000/ts/baz/last/5/filter/colour/equals/red/count
{"count":3}

A query across a time range

curl -k https://localhost:8000/ts/boz/range/3/5
[{"timestamp":5,"data":{"value":500}},{"timestamp":4,"data":{"value":400}},{"timestamp":3,"data":{"value":300}}]

Statistical analysis across different time series

curl -k https://localhost:8000/ts/foo,bar,baz,boz/last/5/sd
{"sd":147.6999091329942}

Other functions that can be used in above example are: sum,max,min,mean,median,count.

deleting data

The delete API supports range querying across multiple time series with support for filtering

curl -k --request DELETE https://localhost:8000/ts/baz/since/0/filter/colour/contains/re
curl -k https://localhost:8000/ts/baz/since/0
[{"timestamp":1545235536095244,"data":{"colour":"blue","value":2}}]

General info

To obtain the current list of time series available

curl -k https://localhost:8000/info/ts/names

To get stats on current time series

curl -k https://localhost:8000/info/ts/stats

performance data

Finding the number of values of a time series held in memory

curl -k https://localhost:8000/ts/foo/memory/length
{"length":5}

Finding the number of values of a time series held on disk

curl -k https://localhost:8000/ts/foo/disk/length
{"length":0}

Finding the length of an index

curl -k https://localhost:8000/ts/foo/index/length
{"length":0}

maintenance

Flushing the memory of all time series to disk

curl -k https://localhost:8000/ctl/ts/sync
curl -k https://localhost:8000/ts/foo,bar,baz,boz/memory/length
{"length":0}