You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
2.9 KiB

5 years ago
# -----------OUTDATED-------------
# -------------------------------------
7 years ago
# Hastic server REST API
## /anomalies
### Get anomalies
`GET /anomalies?id=<predictor_id>[&name=<anomaly_name>]`
7 years ago
NOTE: `name` param is deprecated, use `id` instead
Return data format:
```
{
"name": "<anomaly_name>",
"metric": "<metric_id>",
"status": "<str>"
}
```
status field can be one of:
- `learning`
- `ready`
- `failed`
### Get anomaly status
`GET /anomalies/status?id=<predictor_id>[&name=<anomaly_name>]`
7 years ago
NOTE: `name` param is deprecated, use `id` instead
Return data format:
```
{
"status": <str>,
"errorMessage": <str>
7 years ago
}
```
status field can be one of:
- `learning`
- `ready`
- `failed`
### Add anomaly
`POST /anomalies`
Data format:
```
{
"name": "cpu_utilization_supervised",
"metric": {
7 years ago
"datasource": "influx accelerometer",
"targets": [
<targets>
]
7 years ago
},
"panelUrl": "http://grafana.example.com/d/oNZ35bWiz/new-dashboard-copy?panelId=2&fullscreen",
"datasource": {
7 years ago
"data": null,
"type": "influxdb",
"method": "GET",
"params": {
"db": "collectd",
"q": "SELECT mean("value") FROM "cpu_value" WHERE ("type_instance" = 'user') AND time >= 1525603866633ms and time <= 1526986266633ms GROUP BY time(10s)",
"epoch": "ms"
}
"url": "api/datasources/proxy/8/query"
}
7 years ago
}
```
`targets` example:
```
{
"alias": "command",
"groupBy": [],
"measurement": "data",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"command"
],
"type": "field"
}
]
],
"tags": []
}
```
Return data format:
```
{
"predictor_id": "<predictor_id>"
7 years ago
}
```
### Delete anpmalies
`DELETE /anomalies`
Data format:
```
{
"id": "<predictor_id>",
7 years ago
"name": "<anomaly_name>" // deprecated, use id instead
}
```
Return data format:
```
Success
```
## /segments
### Get segments
`GET /segments?predictor_id=<predictor_id>[&last_segment=<id>][&from=<time_from>][&to=<time_to>]`
7 years ago
Return data format:
```
{
"segments": [
{
"id": 0,
"start": 1392765184318,
"finish": 1397243699000,
"labeled": true
},
...
]
}
```
### Update segments
`PATCH /segments`
Data format:
```
{
"predictor_id": "<predictor_id>",
7 years ago
"name": "<anomaly_name>", // deprecated, use id instead
"added_segments": [
{
"start": 1397164656000,
"finish": 1397243699000
},
...
],
"removed_segments": [3, 9]
}
```
Return data format:
```
{
"added_ids": [12, ...]
}
```
## /alerts
### Check if alert is enabled for anomaly
`GET /alerts?predictor_id=<predictor_id>`
7 years ago
Return data format:
```
{
"enable": true
}
```
### Enable / disable alert for anomaly
`POST /alerts`
Data format:
```
{
"predictor_id": "<predictor_id>",
7 years ago
"enable": true
}
```
Return data format:
```
{
"status": "Ok"
}
```