diff options
Diffstat (limited to 'web/api/web_api_v1.c')
-rw-r--r-- | web/api/web_api_v1.c | 88 |
1 files changed, 10 insertions, 78 deletions
diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c index 2b8e2d8e77..f261b8ee59 100644 --- a/web/api/web_api_v1.c +++ b/web/api/web_api_v1.c @@ -1329,81 +1329,15 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb) } #if defined(ENABLE_ML) -int web_client_api_request_v1_anomaly_events(RRDHOST *host, struct web_client *w, char *url) { - if (!netdata_ready) - return HTTP_RESP_BACKEND_FETCH_FAILED; - - uint32_t after = 0, before = 0; - - while (url) { - char *value = mystrsep(&url, "&"); - if (!value || !*value) - continue; - - char *name = mystrsep(&value, "="); - if (!name || !*name) - continue; - if (!value || !*value) - continue; - - if (!strcmp(name, "after")) - after = (uint32_t) (strtoul(value, NULL, 0) / 1000); - else if (!strcmp(name, "before")) - before = (uint32_t) (strtoul(value, NULL, 0) / 1000); - } - - char *s; - if (!before || !after) - s = strdupz("{\"error\": \"missing after/before parameters\" }\n"); - else { - s = ml_get_anomaly_events(host, "AD1", 1, after, before); - if (!s) - s = strdupz("{\"error\": \"json string is empty\" }\n"); - } - - BUFFER *wb = w->response.data; - buffer_flush(wb); - - wb->contenttype = CT_APPLICATION_JSON; - buffer_strcat(wb, s); - buffer_no_cacheable(wb); - - freez(s); - - return HTTP_RESP_OK; -} +int web_client_api_request_v1_ml_info(RRDHOST *host, struct web_client *w, char *url) { + (void) url; -int web_client_api_request_v1_anomaly_event_info(RRDHOST *host, struct web_client *w, char *url) { if (!netdata_ready) return HTTP_RESP_BACKEND_FETCH_FAILED; - uint32_t after = 0, before = 0; - - while (url) { - char *value = mystrsep(&url, "&"); - if (!value || !*value) - continue; - - char *name = mystrsep(&value, "="); - if (!name || !*name) - continue; - if (!value || !*value) - continue; - - if (!strcmp(name, "after")) - after = (uint32_t) strtoul(value, NULL, 0); - else if (!strcmp(name, "before")) - before = (uint32_t) strtoul(value, NULL, 0); - } - - char *s; - if (!before || !after) - s = strdupz("{\"error\": \"missing after/before parameters\" }\n"); - else { - s = ml_get_anomaly_event_info(host, "AD1", 1, after, before); - if (!s) - s = strdupz("{\"error\": \"json string is empty\" }\n"); - } + char *s = ml_get_host_runtime_info(host); + if (!s) + s = strdupz("{\"error\": \"json string is empty\" }\n"); BUFFER *wb = w->response.data; buffer_flush(wb); @@ -1415,13 +1349,13 @@ int web_client_api_request_v1_anomaly_event_info(RRDHOST *host, struct web_clien return HTTP_RESP_OK; } -int web_client_api_request_v1_ml_info(RRDHOST *host, struct web_client *w, char *url) { +int web_client_api_request_v1_ml_models(RRDHOST *host, struct web_client *w, char *url) { (void) url; if (!netdata_ready) return HTTP_RESP_BACKEND_FETCH_FAILED; - char *s = ml_get_host_runtime_info(host); + char *s = ml_get_host_models(host); if (!s) s = strdupz("{\"error\": \"json string is empty\" }\n"); @@ -1434,8 +1368,7 @@ int web_client_api_request_v1_ml_info(RRDHOST *host, struct web_client *w, char freez(s); return HTTP_RESP_OK; } - -#endif // defined(ENABLE_ML) +#endif inline int web_client_api_request_v1_info(RRDHOST *host, struct web_client *w, char *url) { (void)url; @@ -1680,9 +1613,8 @@ static struct api_command { { "allmetrics", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_allmetrics }, #if defined(ENABLE_ML) - { "anomaly_events", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_anomaly_events }, - { "anomaly_event_info", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_anomaly_event_info }, - { "ml_info", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_ml_info }, + { "ml_info", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_ml_info }, + { "ml_models", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_ml_models }, #endif { "manage/health", 0, WEB_CLIENT_ACL_MGMT, web_client_api_request_v1_mgmt_health }, |