summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2020-02-07 20:13:26 +0000
committerGitHub <noreply@github.com>2020-02-07 12:13:26 -0800
commit57055c9ac18e70a812aec4230219e928405cbb26 (patch)
treed5bc68e600d717199da161aaabf74d2c2591fe20 /web
parent4dc217a48a0b337e1f0baa13faa93a12c575a500 (diff)
alarms_values: New endpoint (#7836)
* alarms_values: New endpoint This commit brings the new endpoint to Netdata * alarms_values: Documentation This commit brings the missing documentation for the PR * alarms_values: New function This commit brings a new code that removes dupplication * alarms_values: Fix typo * alarms_values: Fix missing word This commit fixes the missing word inside the documentation * alarms_values: Fix order This commit fixes the order of the alarm answer * alarms_values: Fixes typo and remmove unecessary variable * alarms_values: Fixes doc Describe all paramenters present in the endpoint * alarms_values: Same options This commit brings the same input pattern for alams and alams_values * alarms_values: Update swagger This commit brings the missing information to swagger json * alarms_values: Update swagger This commit brings the missing information to swagger yaml
Diffstat (limited to 'web')
-rw-r--r--web/api/netdata-swagger.json51
-rw-r--r--web/api/netdata-swagger.yaml38
-rw-r--r--web/api/web_api_v1.c21
-rw-r--r--web/api/web_api_v1.h1
4 files changed, 107 insertions, 4 deletions
diff --git a/web/api/netdata-swagger.json b/web/api/netdata-swagger.json
index aeac6e33d8..1e15dfa110 100644
--- a/web/api/netdata-swagger.json
+++ b/web/api/netdata-swagger.json
@@ -812,7 +812,7 @@
"/alarms": {
"get": {
"summary": "Get a list of active or raised alarms on the server",
- "description": "The alarms endpoint returns the list of all raised or enabled alarms on the netdata server. Called without any parameters, the raised alarms in state WARNING or CRITICAL are returned. By passing \"?all\", all the enabled alarms are returned.",
+ "description": "The alarms endpoint returns the list of all raised or enabled alarms on the Netdata agent. Called without any parameters, the raised alarms in state WARNING or CRITICAL are returned, the same response is delivered when \"?active\" is passed in the URL. By passing \"?all\", all the enabled alarms are returned.",
"parameters": [
{
"name": "all",
@@ -823,6 +823,16 @@
"schema": {
"type": "boolean"
}
+ },
+ {
+ "name": "active",
+ "in": "query",
+ "description": "If passed, the raised alarms in state WARNING or CRITICAL are returned.",
+ "required": false,
+ "allowEmptyValue": true,
+ "schema": {
+ "type": "boolean"
+ }
}
],
"responses": {
@@ -839,6 +849,45 @@
}
}
},
+ "/alarms_values": {
+ "get": {
+ "summary": "Get a list of active or raised alarms on the server",
+ "description": "The alarms endpoint returns the list of all raised or enabled alarms on the Netdata agent. Called without any parameters, the raised alarms in state WARNING or CRITICAL are returned, the same response is delivered when \"?active\" is passed in the URL. By passing \"?all\", all the enabled alarms are returned.",
+ "parameters": [
+ {
+ "name": "all",
+ "in": "query",
+ "description": "If passed, all enabled alarms are returned.",
+ "required": false,
+ "allowEmptyValue": true,
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ {
+ "name": "active",
+ "in": "query",
+ "description": "If passed, the raised alarms in state WARNING or CRITICAL are returned.",
+ "required": false,
+ "allowEmptyValue": true,
+ "schema": {
+ "type": "boolean"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "An object containing general info and a linked list of alarms.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/alarms_values"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/alarm_log": {
"get": {
"summary": "Retrieves the entries of the alarm log",
diff --git a/web/api/netdata-swagger.yaml b/web/api/netdata-swagger.yaml
index 06e456ad67..0efb2e372c 100644
--- a/web/api/netdata-swagger.yaml
+++ b/web/api/netdata-swagger.yaml
@@ -679,6 +679,13 @@ paths:
allowEmptyValue: true
schema:
type: boolean
+ - name: active
+ in: query
+ description: If passed, the raised alarms in state WARNING or CRITICAL are returned.
+ required: false
+ allowEmptyValue: true
+ schema:
+ type: boolean
responses:
"200":
description: An object containing general info and a linked list of alarms.
@@ -686,6 +693,37 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/alarms"
+ /alarms_values:
+ get:
+ summary: Get a list of active or raised alarms on the server
+ description: The alarms_values endpoint returns the list of all raised or enabled alarms on
+ the netdata server. Called without any parameters, the raised alarms in
+ state WARNING or CRITICAL are returned. By passing "?all", all the
+ enabled alarms are returned.
+ This option output differs from `/alarms` in the number of variables delivered. This endpoint gives
+ to user `id`, `value` and alarm `status`.
+ parameters:
+ - name: all
+ in: query
+ description: If passed, all enabled alarms are returned.
+ required: false
+ allowEmptyValue: true
+ schema:
+ type: boolean
+ - name: active
+ in: query
+ description: If passed, the raised alarms in state WARNING or CRITICAL are returned.
+ required: false
+ allowEmptyValue: true
+ schema:
+ type: boolean
+ responses:
+ "200":
+ description: An object containing general info and a linked list of alarms.
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/alarms_values"
/alarm_log:
get:
summary: Retrieves the entries of the alarm log
diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c
index fd111dc40d..70bea8d667 100644
--- a/web/api/web_api_v1.c
+++ b/web/api/web_api_v1.c
@@ -196,10 +196,8 @@ inline uint32_t web_client_api_request_v1_data_google_format(char *name) {
return DATASOURCE_JSON;
}
-
-inline int web_client_api_request_v1_alarms(RRDHOST *host, struct web_client *w, char *url) {
+int web_client_api_request_v1_alarms_select (char *url) {
int all = 0;
-
while(url) {
char *value = mystrsep(&url, "&");
if (!value || !*value) continue;
@@ -208,6 +206,12 @@ inline int web_client_api_request_v1_alarms(RRDHOST *host, struct web_client *w,
else if(!strcmp(value, "active")) all = 0;
}
+ return all;
+}
+
+inline int web_client_api_request_v1_alarms(RRDHOST *host, struct web_client *w, char *url) {
+ int all = web_client_api_request_v1_alarms_select(url);
+
buffer_flush(w->response.data);
w->response.data->contenttype = CT_APPLICATION_JSON;
health_alarms2json(host, w->response.data, all);
@@ -215,6 +219,16 @@ inline int web_client_api_request_v1_alarms(RRDHOST *host, struct web_client *w,
return HTTP_RESP_OK;
}
+inline int web_client_api_request_v1_alarms_values(RRDHOST *host, struct web_client *w, char *url) {
+ int all = web_client_api_request_v1_alarms_select(url);
+
+ buffer_flush(w->response.data);
+ w->response.data->contenttype = CT_APPLICATION_JSON;
+ health_alarms_values2json(host, w->response.data, all);
+ buffer_no_cacheable(w->response.data);
+ return HTTP_RESP_OK;
+}
+
inline int web_client_api_request_v1_alarm_count(RRDHOST *host, struct web_client *w, char *url) {
RRDCALC_STATUS status = RRDCALC_STATUS_RAISED;
BUFFER *contexts = NULL;
@@ -878,6 +892,7 @@ static struct api_command {
{ "badge.svg", 0, WEB_CLIENT_ACL_DASHBOARD|WEB_CLIENT_ACL_BADGE, web_client_api_request_v1_badge },
{ "alarms", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_alarms },
+ { "alarms_values", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_alarms_values },
{ "alarm_log", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_alarm_log },
{ "alarm_variables", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_alarm_variables },
{ "alarm_count", 0, WEB_CLIENT_ACL_DASHBOARD, web_client_api_request_v1_alarm_count },
diff --git a/web/api/web_api_v1.h b/web/api/web_api_v1.h
index ca853ceacd..2748023851 100644
--- a/web/api/web_api_v1.h
+++ b/web/api/web_api_v1.h
@@ -13,6 +13,7 @@ extern uint32_t web_client_api_request_v1_data_format(char *name);
extern uint32_t web_client_api_request_v1_data_google_format(char *name);
extern int web_client_api_request_v1_alarms(RRDHOST *host, struct web_client *w, char *url);
+extern int web_client_api_request_v1_alarms_values(RRDHOST *host, struct web_client *w, char *url);
extern int web_client_api_request_v1_alarm_log(RRDHOST *host, struct web_client *w, char *url);
extern int web_client_api_request_single_chart(RRDHOST *host, struct web_client *w, char *url, void callback(RRDSET *st, BUFFER *buf));
extern int web_client_api_request_v1_alarm_variables(RRDHOST *host, struct web_client *w, char *url);