summaryrefslogtreecommitdiffstats
path: root/web/api
diff options
context:
space:
mode:
authorVladimir Kobal <vlad@prokk.net>2020-01-06 17:34:49 +0200
committerGitHub <noreply@github.com>2020-01-06 17:34:49 +0200
commit8cf58891941b7c4c4b1f35f6e9b6db770eb878ab (patch)
tree1cef3ea2e65fdb202c1cd5a580cf8b7eed779f48 /web/api
parentcd7abaa69d32f119706ff75e0d1529f8087d0f0d (diff)
Clean up host labels in API responses (#7616)
* Remove host labels from the Swagger specification * Remove host labels from the api responses
Diffstat (limited to 'web/api')
-rw-r--r--web/api/formatters/charts2json.c7
-rw-r--r--web/api/formatters/json_wrapper.c27
-rw-r--r--web/api/formatters/rrdset2json.c6
-rw-r--r--web/api/netdata-swagger.json55
-rw-r--r--web/api/netdata-swagger.yaml40
-rw-r--r--web/api/web_api_v1.c2
6 files changed, 7 insertions, 130 deletions
diff --git a/web/api/formatters/charts2json.c b/web/api/formatters/charts2json.c
index efe6eaa257..db3ef37eaf 100644
--- a/web/api/formatters/charts2json.c
+++ b/web/api/formatters/charts2json.c
@@ -56,6 +56,7 @@ void charts2json(RRDHOST *host, BUFFER *wb) {
",\n\t\"history\": %ld"
",\n\t\"memory_mode\": \"%s\""
",\n\t\"custom_info\": \"%s\""
+ ",\n\t\"charts\": {"
, host->hostname
, host->program_version
, get_release_channel()
@@ -67,12 +68,6 @@ void charts2json(RRDHOST *host, BUFFER *wb) {
, custom_dashboard_info_js_filename
);
- buffer_strcat(wb, ",\n\t\"labels\": {\n");
- host_labels2json(host, wb, 2);
- buffer_strcat(wb, "\t}");
-
- buffer_strcat(wb, ",\n\t\"charts\": {");
-
c = 0;
rrdhost_rdlock(host);
rrdset_foreach_read(st, host) {
diff --git a/web/api/formatters/json_wrapper.c b/web/api/formatters/json_wrapper.c
index 08354d0465..5ef2caf101 100644
--- a/web/api/formatters/json_wrapper.c
+++ b/web/api/formatters/json_wrapper.c
@@ -26,35 +26,16 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS
" %sapi%s: 1,\n"
" %sid%s: %s%s%s,\n"
" %sname%s: %s%s%s,\n"
- , kq, kq
- , kq, kq, sq, r->st->id, sq
- , kq, kq, sq, r->st->name, sq);
-
- RRDHOST *host = r->st->rrdhost;
- buffer_sprintf(wb, " %slabels%s: {\n", kq, kq);
-
- int count = 0;
- netdata_rwlock_rdlock(&host->labels_rwlock);
- for (struct label *label = host->labels; label; label = label->next) {
- if(count > 0) buffer_strcat(wb, ",\n");
-
- char value[CONFIG_MAX_VALUE * 2 + 1];
- escape_json_string(value, label->value, CONFIG_MAX_VALUE * 2);
- buffer_sprintf(wb, " %s%s%s: %s%s%s", kq, label->key, kq, sq, value, sq);
-
- count++;
- }
- netdata_rwlock_unlock(&host->labels_rwlock);
-
- buffer_strcat(wb, "\n },\n");
-
- buffer_sprintf(wb, " %sview_update_every%s: %d,\n"
+ " %sview_update_every%s: %d,\n"
" %supdate_every%s: %d,\n"
" %sfirst_entry%s: %u,\n"
" %slast_entry%s: %u,\n"
" %sbefore%s: %u,\n"
" %safter%s: %u,\n"
" %sdimension_names%s: ["
+ , kq, kq
+ , kq, kq, sq, r->st->id, sq
+ , kq, kq, sq, r->st->name, sq
, kq, kq, r->update_every
, kq, kq, r->st->update_every
, kq, kq, (uint32_t)rrdset_first_entry_t(r->st)
diff --git a/web/api/formatters/rrdset2json.c b/web/api/formatters/rrdset2json.c
index 8e3297d5b3..4d91399270 100644
--- a/web/api/formatters/rrdset2json.c
+++ b/web/api/formatters/rrdset2json.c
@@ -73,11 +73,7 @@ void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memor
if(dimensions_count) *dimensions_count += dimensions;
if(memory_used) *memory_used += memory;
- buffer_strcat(wb, "\n\t\t\t},\n\t\t\t\"labels\": {\n");
- host_labels2json(st->rrdhost, wb, 4);
- buffer_strcat(wb, "\t\t\t}");
-
- buffer_sprintf(wb, ",\n\t\t\t\"chart_variables\": ");
+ buffer_sprintf(wb, "\n\t\t\t},\n\t\t\t\"chart_variables\": ");
health_api_v1_chart_custom_variables2json(st, wb);
buffer_strcat(wb, ",\n\t\t\t\"green\": ");
diff --git a/web/api/netdata-swagger.json b/web/api/netdata-swagger.json
index 9c8c4ac063..6a222a00ab 100644
--- a/web/api/netdata-swagger.json
+++ b/web/api/netdata-swagger.json
@@ -1079,17 +1079,6 @@
"type": "number",
"description": "The default update frequency of the netdata server. All charts have an update frequency equal or bigger than this."
},
- "labels": {
- "type": "object",
- "description": "List of host labels.",
- "properties": {
- "app": {
- "type": "string",
- "description": "Host label.",
- "example": "netdata"
- }
- }
- },
"charts": {
"type": "object",
"description": "An object containing all the chart objects available at the netdata server. This is used as an indexed array. The key of each chart object is the id of the chart.",
@@ -1192,17 +1181,6 @@
}
}
},
- "labels": {
- "type": "object",
- "description": "List of host labels.",
- "properties": {
- "app": {
- "type": "string",
- "description": "Host label.",
- "example": "netdata"
- }
- }
- },
"chart_variables": {
"type": "object",
"additionalProperties": {
@@ -1244,17 +1222,6 @@
"type": "string",
"description": "The host containing the chart."
},
- "labels": {
- "type": "object",
- "description": "List of host labels.",
- "properties": {
- "app": {
- "type": "string",
- "description": "Host label.",
- "example": "netdata"
- }
- }
- },
"chart_variables": {
"type": "object",
"additionalProperties": {
@@ -1321,17 +1288,6 @@
"type": "string",
"description": "The name of the chart."
},
- "labels": {
- "type": "object",
- "description": "List of host labels.",
- "properties": {
- "app": {
- "type": "string",
- "description": "Host label.",
- "example": "netdata"
- }
- }
- },
"update_every": {
"type": "number",
"description": "The update frequency of this chart, in seconds. One value every this amount of time is kept in the round robin database (indepedently of the current view)."
@@ -1739,17 +1695,6 @@
}
}
}
- },
- "labels": {
- "type": "object",
- "description": "List of host labels.",
- "properties": {
- "app": {
- "type": "string",
- "description": "Host label.",
- "example": "netdata"
- }
- }
}
}
},
diff --git a/web/api/netdata-swagger.yaml b/web/api/netdata-swagger.yaml
index e5e8226bc8..669d1d1917 100644
--- a/web/api/netdata-swagger.yaml
+++ b/web/api/netdata-swagger.yaml
@@ -878,14 +878,6 @@ components:
type: number
description: The default update frequency of the netdata server. All charts have
an update frequency equal or bigger than this.
- labels:
- type: object
- description: List of host labels.
- properties:
- app:
- type: string
- description: Host label.
- example: netdata
charts:
type: object
description: An object containing all the chart objects available at the netdata
@@ -979,14 +971,6 @@ components:
name:
type: string
description: The name of the dimension
- labels:
- type: object
- description: List of host labels.
- properties:
- app:
- type: string
- description: Host label.
- example: netdata
chart_variables:
type: object
additionalProperties:
@@ -1018,14 +1002,6 @@ components:
host:
type: string
description: The host containing the chart.
- labels:
- type: object
- description: List of host labels.
- properties:
- app:
- type: string
- description: Host label.
- example: netdata
chart_variables:
type: object
additionalProperties:
@@ -1073,14 +1049,6 @@ components:
name:
type: string
description: The name of the chart.
- labels:
- type: object
- description: List of host labels.
- properties:
- app:
- type: string
- description: Host label.
- example: netdata
update_every:
type: number
description: The update frequency of this chart, in seconds. One value every this
@@ -1373,14 +1341,6 @@ components:
format: nullable
value:
type: number
- labels:
- type: object
- description: List of host labels.
- properties:
- app:
- type: string
- description: Host label.
- example: netdata
alarm_log_entry:
type: object
properties:
diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c
index 9c3a1f75d8..072daea2ae 100644
--- a/web/api/web_api_v1.c
+++ b/web/api/web_api_v1.c
@@ -822,7 +822,7 @@ inline int web_client_api_request_v1_info(RRDHOST *host, struct web_client *w, c
buffer_sprintf(wb, "\t\"container\": \"%s\",\n", (host->system_info->container) ? host->system_info->container : "");
buffer_sprintf(wb, "\t\"container_detection\": \"%s\",\n", (host->system_info->container_detection) ? host->system_info->container_detection : "");
- buffer_strcat(wb, "\t\"labels\": {\n");
+ buffer_strcat(wb, "\t\"host_labels\": {\n");
host_labels2json(host, wb, 2);
buffer_strcat(wb, "\t},\n");