Tutorial

starting server

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

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.
1
curl -k --request POST --data '[{"value": 1}, {"value": 2}, {"value": 3}, {"value": 4}, {"value": 5}]' https://localhost:8000/ts/foo
2
curl -k --request POST --data '[{"value": 10}, {"value": 20}, {"value": 30}, {"value": 40}, {"value": 50}]' https://localhost:8000/ts/bar
3
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
4
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
Copied!

retrieving data

A typical request to obtain the last n values
1
curl -k https://localhost:8000/ts/foo/last/3
Copied!
1
[{"timestamp":1545232878575320,"data":{"value":5}},{"timestamp":1545232878575311,"data":{"value":4}},{"timestamp":1545232878575302,"data":{"value":3}}]
Copied!
Finding the combined length of two time series
1
curl -k https://localhost:8000/ts/foo,bar/length
Copied!
1
{"length":10}
Copied!
A range query from a specific point in time
1
curl -k https://localhost:8000/ts/boz/since/4
Copied!
1
[{"timestamp":5,"data":{"value":500}},{"timestamp":4,"data":{"value":400}}]
Copied!
A query which filters the result based on matching tagged values and then applies an aggregation function
1
curl -k https://localhost:8000/ts/baz/last/5/filter/colour/equals/red/count
Copied!
1
{"count":3}
Copied!
A query across a time range
1
curl -k https://localhost:8000/ts/boz/range/3/5
Copied!
1
[{"timestamp":5,"data":{"value":500}},{"timestamp":4,"data":{"value":400}},{"timestamp":3,"data":{"value":300}}]
Copied!
Statistical analysis across different time series
1
curl -k https://localhost:8000/ts/foo,bar,baz,boz/last/5/sd
Copied!
1
{"sd":147.6999091329942}
Copied!
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
1
curl -k --request DELETE https://localhost:8000/ts/baz/since/0/filter/colour/contains/re
2
curl -k https://localhost:8000/ts/baz/since/0
Copied!
1
[{"timestamp":1545235536095244,"data":{"colour":"blue","value":2}}]
Copied!

General info

To obtain the current list of time series available
1
curl -k https://localhost:8000/info/ts/names
Copied!
To get stats on current time series
1
curl -k https://localhost:8000/info/ts/stats
Copied!

performance data

Finding the number of values of a time series held in memory
1
curl -k https://localhost:8000/ts/foo/memory/length
Copied!
1
{"length":5}
Copied!
Finding the number of values of a time series held on disk
1
curl -k https://localhost:8000/ts/foo/disk/length
Copied!
1
{"length":0}
Copied!
Finding the length of an index
1
curl -k https://localhost:8000/ts/foo/index/length
Copied!
1
{"length":0}
Copied!

maintenance

Flushing the memory of all time series to disk
1
curl -k https://localhost:8000/ctl/ts/sync
Copied!
1
curl -k https://localhost:8000/ts/foo,bar,baz,boz/memory/length
Copied!
1
{"length":0}
Copied!
Last modified 1yr ago