Tutorial

Create a docker network to use

1
docker network create nibble
Copied!

Start one backend

1
docker run -it --name foo --network="nibble" jptmoore/nibbledb
Copied!

Start another backend

1
docker run -it --name bar --network="nibble" jptmoore/nibbledb
Copied!

Start the gateway

1
docker run -p 5000:5000 -it --network="nibble" jptmoore/nibblegw --hosts "http://foo:8000, http://bar:8000"
Copied!

Post some data

1
curl --request POST --data '[{"value": 1}, {"value": 2}, {"value": 3}, {"value": 4}, {"value": 5}]' http://localhost:5000/ts/foo
2
curl --request POST --data '[{"value": 6}, {"value": 7}, {"value": 8}, {"value": 9}, {"value": 10}]' http://localhost:5000/ts/foo
3
curl --request POST --data '[{"value": 11}, {"value": 12}, {"value": 13}, {"value": 14}, {"value": 15}]' http://localhost:5000/ts/foo
Copied!
The data is distributed across the two backends.

Run a query

1
curl http://localhost:5000/ts/foo/length
Copied!
1
{"length":15}
Copied!

Add more backend hosts

1
curl -X POST http://localhost:5000/ctl/host/add -d '[{"host":"http://foo:8000"}]'
Copied!
1
Error:host already exists
Copied!
1
docker run -it --name baz --network="nibble" jptmoore/nibbledb
Copied!
1
curl -X POST http://localhost:5000/ctl/host/add -d '[{"host":"http://baz:8000"}]'
Copied!

Removing backend hosts

1
curl -X POST http://localhost:5000/ctl/host/remove -d '[{"host":"http://baz:8000"}]'
Copied!
The data from the removed backend host will be distributed across the remaining backends.

List the backend hosts

1
curl http://localhost:5000/info/host/list
Copied!
1
{"hosts":["http://foo:8000","http://bar:8000"]}
Copied!

Get the number of backend hosts

1
curl http://localhost:5000/info/host/count
Copied!
1
{"count":2}
Copied!

Get names of time series

1
curl http://localhost:5000/info/ts/names
Copied!
1
{"timeseries":["foo"]}
Copied!
Which means across our backend servers named foo and bar we have created one time series called foo.

Get stats on the backend servers

1
curl http://localhost:5000/info/ts/stats
Copied!
1
[
2
{
3
"http://foo:8000/info/ts/stats": [
4
{
5
"length": [
6
{
7
"foo": 10
8
}
9
]
10
},
11
{
12
"length_in_memory": [
13
{
14
"foo": 10
15
}
16
]
17
},
18
{
19
"length_on_disk": [
20
{
21
"foo": 0
22
}
23
]
24
},
25
{
26
"length_of_index": [
27
{
28
"foo": 0
29
}
30
]
31
}
32
]
33
},
34
{
35
"http://bar:8000/info/ts/stats": [
36
{
37
"length": [
38
{
39
"foo": 5
40
}
41
]
42
},
43
{
44
"length_in_memory": [
45
{
46
"foo": 5
47
}
48
]
49
},
50
{
51
"length_on_disk": [
52
{
53
"foo": 0
54
}
55
]
56
},
57
{
58
"length_of_index": [
59
{
60
"foo": 0
61
}
62
]
63
}
64
]
65
}
66
]
Copied!
Last modified 1yr ago