Skip to content

Commit

Permalink
info API minor enhancements
Browse files Browse the repository at this point in the history
Return 503 instead of 400 when netdata hasnt started yet, move struct definitions in .c, swagger update (netdata#5891)
  • Loading branch information
cakrit authored and jackyhuang85 committed Jan 1, 2020
1 parent 099a142 commit b06073e
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 12 deletions.
12 changes: 12 additions & 0 deletions web/api/formatters/charts2json.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions web/api/formatters/charts2json.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
89 changes: 88 additions & 1 deletion web/api/netdata-swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
}
}
Expand Down Expand Up @@ -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.",
Expand Down
70 changes: 70 additions & 0 deletions web/api/netdata-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion web/api/web_api_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b06073e

Please sign in to comment.