From 8f36f5bcee2c467b0ea2b71d205cef44d6c0de52 Mon Sep 17 00:00:00 2001 From: Chris Akritidis <43294513+cakrit@users.noreply.github.com> Date: Thu, 2 May 2019 13:04:15 +0300 Subject: info API minor enhancements Return 503 instead of 400 when netdata hasnt started yet, move struct definitions in .c, swagger update (#5891) --- web/api/formatters/charts2json.c | 12 ++++++ web/api/formatters/charts2json.h | 10 ----- web/api/netdata-swagger.json | 89 +++++++++++++++++++++++++++++++++++++++- web/api/netdata-swagger.yaml | 70 +++++++++++++++++++++++++++++++ web/api/web_api_v1.c | 2 +- 5 files changed, 171 insertions(+), 12 deletions(-) (limited to 'web/api') diff --git a/web/api/formatters/charts2json.c b/web/api/formatters/charts2json.c index e3dbd40dc3..e4e2f4dfa4 100644 --- a/web/api/formatters/charts2json.c +++ b/web/api/formatters/charts2json.c @@ -136,6 +136,18 @@ void charts2json(RRDHOST *host, BUFFER *wb) { buffer_sprintf(wb, "\n\t]\n}\n"); } +// generate collectors list for the api/v1/info call + +struct collector { + char *plugin; + char *module; +}; + +struct array_printer { + int c; + BUFFER *wb; +}; + int print_collector(void *entry, void *data) { struct array_printer *ap = (struct array_printer *)data; BUFFER *wb = ap->wb; diff --git a/web/api/formatters/charts2json.h b/web/api/formatters/charts2json.h index 348e736895..926e76d50b 100644 --- a/web/api/formatters/charts2json.h +++ b/web/api/formatters/charts2json.h @@ -5,16 +5,6 @@ #include "rrd2json.h" -struct collector { - char *plugin; - char *module; -}; - -struct array_printer { - int c; - BUFFER *wb; -}; - extern void charts2json(RRDHOST *host, BUFFER *wb); extern void chartcollectors2json(RRDHOST *host, BUFFER *wb); diff --git a/web/api/netdata-swagger.json b/web/api/netdata-swagger.json index 99ed95209f..2fa55c4faa 100644 --- a/web/api/netdata-swagger.json +++ b/web/api/netdata-swagger.json @@ -18,13 +18,16 @@ "/info": { "get": { "summary": "Get netdata basic information", - "description": "The info endpoint returns basic information about netdata. It provides:\n* netdata version\n* netdata unique id\n* list of hosts mirrored (includes itself)\n* number of alarms in the host\n * number of alarms in normal state\n * number of alarms in warning state\n * number of alarms in critical state\n", + "description": "The info endpoint returns basic information about netdata. It provides:\n* netdata version\n* netdata unique id\n* list of hosts mirrored (includes itself)\n* Operating System, Virtualization and Container technology information\n* List of active collector plugins and modules\n* number of alarms in the host\n * number of alarms in normal state\n * number of alarms in warning state\n * number of alarms in critical state\n", "responses": { "200": { "description": "netdata basic information", "schema": { "$ref": "#/definitions/info" } + }, + "503": { + "description": "netdata daemon not ready (used for health checks)" } } } @@ -706,6 +709,90 @@ "host2.example.com" ] }, + "os_name": { + "type": "string", + "description": "Operating System Name", + "example": "Manjaro Linux" + }, + "os_id": { + "type": "string", + "description": "Operating System ID", + "example": "manjaro" + }, + "os_id_like": { + "type": "string", + "description": "Known OS similar to this OS", + "example": "arch" + }, + "os_version": { + "type": "string", + "description": "Operating System Version", + "example": "18.0.4" + }, + "os_version_id": { + "type": "string", + "description": "Operating System Version ID", + "example": "unknown" + }, + "os_detection": { + "type": "string", + "description": "OS parameters detection method", + "example": "Mixed" + }, + "kernel_name": { + "type": "string", + "description": "Kernel Name", + "example": "Linux" + }, + "kernel_version": { + "type": "string", + "description": "Kernel Version", + "example": "4.19.32-1-MANJARO" + }, + "architecture": { + "type": "string", + "description": "Kernel architecture", + "example": "x86_64" + }, + "virtualization": { + "type": "string", + "description": "Virtualization Type", + "example": "kvm" + }, + "virt_detection": { + "type": "string", + "description": "Virtualization detection method", + "example": "systemd-detect-virt" + }, + "container": { + "type": "string", + "description": "Container technology", + "example": "docker" + }, + "container_detection": { + "type": "string", + "description": "Container technology detection method", + "example": "dockerenv" + }, + "collectors": { + "type": "array", + "items": { + "type": "object", + "description": "Array of collector plugins and modules", + "properties": { + "plugin": { + "type": "string", + "description": "Collector plugin", + "example": "python.d.plugin" + }, + "module": { + "type": "string", + "description": "Module of the collector plugin", + "example": "dockerd" + } + } + } + }, "alarms": { "type": "object", "description": "number of alarms in the server.", diff --git a/web/api/netdata-swagger.yaml b/web/api/netdata-swagger.yaml index e5689e3927..c021efefa7 100644 --- a/web/api/netdata-swagger.yaml +++ b/web/api/netdata-swagger.yaml @@ -20,6 +20,8 @@ paths: * netdata version * netdata unique id * list of hosts mirrored (includes itself) + * Operating System, Virtualization and Container technology information + * List of active collector plugins and modules * number of alarms in the host * number of alarms in normal state * number of alarms in warning state @@ -29,6 +31,8 @@ paths: description: netdata basic information schema: $ref: '#/definitions/info' + '503': + description: netdata daemon not ready (used for health checks) /charts: get: summary: 'Get a list of all charts available at the server' @@ -460,6 +464,72 @@ definitions: example: - host1.example.com - host2.example.com + os_name: + type: string + description: Operating System Name + example: Manjaro Linux + os_id: + type: string + description: Operating System ID + example: manjaro + os_id_like: + type: string + description: Known OS similar to this OS + example: arch + os_version: + type: string + description: Operating System Version + example: 18.0.4 + os_version_id: + type: string + description: Operating System Version ID + example: unknown + os_detection: + type: string + description: OS parameters detection method + example: Mixed + kernel_name: + type: string + description: Kernel Name + example: Linux + kernel_version: + type: string + description: Kernel Version + example: 4.19.32-1-MANJARO + architecture: + type: string + description: Kernel architecture + example: x86_64 + virtualization: + type: string + description: Virtualization Type + example: kvm + virt_detection: + type: string + description: Virtualization detection method + example: systemd-detect-virt + container: + type: string + description: Container technology + example: docker + container_detection: + type: string + description: Container technology detection method + example: dockerenv + collectors: + type: array + items: + type: object + description: Array of collector plugins and modules + properties: + plugin: + type: string + description: Collector plugin + example: python.d.plugin + module: + type: string + description: Module of the collector plugin + example: dockerd alarms: type: object description: number of alarms in the server. diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c index 528794c307..e418b03919 100644 --- a/web/api/web_api_v1.c +++ b/web/api/web_api_v1.c @@ -717,7 +717,7 @@ static inline void web_client_api_request_v1_info_mirrored_hosts(BUFFER *wb) { inline int web_client_api_request_v1_info(RRDHOST *host, struct web_client *w, char *url) { (void)url; - if (!netdata_ready) return 400; + if (!netdata_ready) return 503; BUFFER *wb = w->response.data; buffer_flush(wb); -- cgit v1.2.3