https://github.com/yaacov/ratsdb
Rest API for time series data bases
https://github.com/yaacov/ratsdb
Last synced: 2 days ago
JSON representation
Rest API for time series data bases
- Host: GitHub
- URL: https://github.com/yaacov/ratsdb
- Owner: yaacov
- License: mit
- Created: 2016-08-21T12:36:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-22T10:39:46.000Z (about 9 years ago)
- Last Synced: 2025-03-16T23:42:13.695Z (7 months ago)
- Language: Go
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ratsdb
Rest API for time series data bases### A Restul API Front end for tsdb's
A Restful API for querying time-value samples. Data is grouped by keys, and labels.
Users can query data using keys and labels. Time-value samples can also grouped in time buckets.### API Path and varialbes
#### Query samples
Method | Path
-------| ----
GET | http://hostname/samples/##### Examples
```
GET: http://localhost:8080/samples/?key=Cats&labels=ginger,tabby
GET: http://localhost:8080/samples/?key=Cats&start=1471787960527&end=1471787971180
```##### Query parameters
name | type | optional | description
-----|------|----------|------------
key | string | optional | sample key
labels | comma separeted strings | optional | comma sepreated list of labels
start | integer | optional | start time in millisecond since Jan 01 1970
end | integer | optional | end time in millisecond since Jan 01 1970
bucket | integer | optional | group samples by milliseconds#### Query one sample
Method | Path
-------| ----
GET | http://hostname/samples/id#### Insert one sample
Method | Path
-------| ----
POST | http://hostname/samples/##### Post body (JSON application/json)
```
{
"key": key,
"value": value,
["labels": comma separated list of labels]
}
```### Backends
- Sqlite (memory)
- Sqlite (file)### Examples
#### Query all samples
http://localhost:8080/samples##### Responce
```
[
{
"id": 1,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787960527,
"value": 2
},
{
"id": 2,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787971180,
"value": 3
},
{
"id": 3,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787976956,
"value": 4
}
]
```### Query one sample by id
GET: http://localhost:8080/samples/2
#### Response
```
{
"id": 2,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787971180,
"value": 3
}
```#### Query by key and labels
GET: http://localhost:8080/samples/?key=Cats&labels=ginger
##### Response
```
[
{
"id": 1,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787960527,
"value": 2
},
{
"id": 2,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787971180,
"value": 3
},
{
"id": 3,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787976956,
"value": 4
}
]
```### Query by time
GET: http://localhost:8080/samples/?key=Cats&start=1471787960527&end=1471787971180
#### Response
```
[
{
"id": 1,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787960527,
"value": 2
}
]
```#### Query using time buckets
GET: http://localhost:8080/samples/?key=Cats&labels=ginger&bucket=10000
##### Response
```
[
{
"count": 1,
"key": "Cats",
"labels": "ginger",
"start": 1471787960527,
"end": 1471787960527,
"min": 2,
"max": 2,
"avg": 2
},
{
"count": 2,
"key": "Cats",
"labels": "ginger",
"start": 1471787971180,
"end": 1471787976956,
"min": 3,
"max": 4,
"avg": 3.5
}
]
```#### Insert new samples
##### Query
POST: http://localhost:8080/samplesField | Content
------| -------------
URL | http://localhost:8080/samples
Body | `{ "key": "Cats", "labels":"tabby,ginger", "value": 2.0 }`##### Response
```
{
"id": 1,
"key": "Cats",
"labels": "tabby,ginger",
"time": 1471787727600,
"value": 2.0
}
```