# Hastic server REST API ## /anomalies ### Get anomalies `GET /anomalies?id=[&name=]` NOTE: `name` param is deprecated, use `id` instead Return data format: ``` { "name": "", "metric": "", "status": "" } ``` status field can be one of: - `learning` - `ready` - `failed` ### Get anomaly status `GET /anomalies/status?id=[&name=]` NOTE: `name` param is deprecated, use `id` instead Return data format: ``` { "status": } ``` status field can be one of: - `learning` - `ready` - `failed` ### Add anomaly `POST /anomalies` Data format: ``` { "name": "cpu_utilization_supervised", "metric": { "datasource": "influx accelerometer", "targets": [ ] }, "panelUrl": "http://grafana.example.com/d/oNZ35bWiz/new-dashboard-copy?panelId=2&fullscreen" } ``` `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: ``` { "anomaly_id": "" } ``` ### Delete anpmalies `DELETE /anomalies` Data format: ``` { "id": "", "name": "" // deprecated, use id instead } ``` Return data format: ``` Success ``` ## /segments ### Get segments `GET /segments?anomaly_id=[&last_segment=][&from=][&to=]` Return data format: ``` { "segments": [ { "id": 0, "start": 1392765184318, "finish": 1397243699000, "labeled": true }, ... ] } ``` ### Update segments `PATCH /segments` Data format: ``` { "anomaly_id": "", "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?anomaly_id=` Return data format: ``` { "enable": true } ``` ### Enable / disable alert for anomaly `POST /alerts` Data format: ``` { "anomaly_id": "", "enable": true } ``` Return data format: ``` { "status": "Ok" } ```