added swagger info about the API
Costa Tsaousis (ktsaou) committed
Dec 8, 2015 at 02:03 UTC
a21ef35015aed48714012364218fdc7088dd2a32
2 files changed
+523
web/netdata-swagger.json
new
+316
@@ -0,0 +1,316 @@
1
+{
2
+ "swagger": "2.0",
3
+ "info": {
4
+ "title": "NetData API",
5
+ "description": "Real time monitoring for linux, over the web!",
6
+ "version": "1.0.0"
7
+ },
8
+ "schemes": [
9
+ "http"
10
+ ],
11
+ "basePath": "/api/v1",
12
+ "produces": [
13
+ "application/json"
14
+ ],
15
+ "paths": {
16
+ "/charts": {
17
+ "get": {
18
+ "summary": "Get a list of all charts available at the server",
19
+ "description": "The charts endpoint returns a summary about all charts stored in the netdata server.",
20
+ "responses": {
21
+ "200": {
22
+ "description": "An array of charts",
23
+ "schema": {
24
+ "type": "array",
25
+ "items": {
26
+ "$ref": "#/definitions/chart_summary"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ },
33
+ "/chart": {
34
+ "get": {
35
+ "summary": "Get info about a specific chart",
36
+ "description": "The Chart endpoint returns detailed information about a chart.",
37
+ "parameters": [
38
+ {
39
+ "name": "chart",
40
+ "in": "query",
41
+ "description": "The id of the chart as returned by the /charts call.",
42
+ "required": true,
43
+ "type": "string",
44
+ "format": "as returned by /charts"
45
+ }
46
+ ],
47
+ "responses": {
48
+ "200": {
49
+ "description": "A javascript object with detailed information about the chart.",
50
+ "schema": {
51
+ "$ref": "#/definitions/chart"
52
+ }
53
+ },
54
+ "404": {
55
+ "description": "No chart with the given id is found."
56
+ }
57
+ }
58
+ }
59
+ },
60
+ "/data": {
61
+ "get": {
62
+ "summary": "Get collected data for a specific chart",
63
+ "description": "The Data endpoint returns data stored in the round robin database of a chart.\n",
64
+ "parameters": [
65
+ {
66
+ "name": "chart",
67
+ "in": "query",
68
+ "description": "The id of the chart as returned by the /charts call.",
69
+ "required": true,
70
+ "type": "string",
71
+ "format": "as returned by /charts",
72
+ "allowEmptyValue": false
73
+ },
74
+ {
75
+ "name": "dimension",
76
+ "in": "query",
77
+ "description": "zero, one or more dimension ids, as returned by the /chart call.",
78
+ "required": false,
79
+ "type": "array",
80
+ "items": {
81
+ "type": "string",
82
+ "collectionFormat": "pipes",
83
+ "format": "as returned by /charts"
84
+ },
85
+ "allowEmptyValue": false
86
+ },
87
+ {
88
+ "name": "after",
89
+ "in": "query",
90
+ "description": "This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.",
91
+ "required": true,
92
+ "type": "number",
93
+ "format": "integer",
94
+ "allowEmptyValue": false,
95
+ "default": -600
96
+ },
97
+ {
98
+ "name": "before",
99
+ "in": "query",
100
+ "description": "This parameter can either be an absolute timestamp specifying the ending point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.",
101
+ "required": false,
102
+ "type": "number",
103
+ "format": "integer",
104
+ "allowEmptyValue": false,
105
+ "default": 0
106
+ },
107
+ {
108
+ "name": "points",
109
+ "in": "query",
110
+ "description": "The number of points to be returned. If not given, or it is <= 0, or it is bigger than the points stored in the round robin database for this chart for the given duration, all the available collected values for the given duration are returned.",
111
+ "required": true,
112
+ "type": "number",
113
+ "format": "integer",
114
+ "allowEmptyValue": false,
115
+ "default": 100
116
+ },
117
+ {
118
+ "name": "group",
119
+ "in": "query",
120
+ "description": "The grouping method. If multiple collected values are to be grouped in order to return fewer points, this parameters defines the method of grouping. Two methods are supported, \"max\" and \"average\". \"max\" is actually calculated on the absolute value collected (so it works for both positive and negative dimesions to return the most extreme value in either direction).",
121
+ "required": true,
122
+ "type": "string",
123
+ "enum": [
124
+ "max",
125
+ "average"
126
+ ],
127
+ "default": "max",
128
+ "allowEmptyValue": false
129
+ },
130
+ {
131
+ "name": "format",
132
+ "in": "query",
133
+ "description": "The format of the data to be returned.",
134
+ "required": true,
135
+ "type": "string",
136
+ "enum": [
137
+ "json",
138
+ "jsonp",
139
+ "csv",
140
+ "tsv",
141
+ "tsv-excel",
142
+ "ssv",
143
+ "ssvcomma",
144
+ "datatable",
145
+ "datasource",
146
+ "html",
147
+ "array"
148
+ ],
149
+ "default": "json",
150
+ "allowEmptyValue": false
151
+ },
152
+ {
153
+ "name": "options",
154
+ "in": "query",
155
+ "description": "Options that affect data generation.",
156
+ "required": false,
157
+ "type": "array",
158
+ "items": {
159
+ "type": "string",
160
+ "enum": [
161
+ "nonzero",
162
+ "flip",
163
+ "jsonwrap",
164
+ "min2max",
165
+ "seconds",
166
+ "milliseconds",
167
+ "abs",
168
+ "absolute",
169
+ "absolute-sum",
170
+ "null2zero",
171
+ "objectrows",
172
+ "google_json"
173
+ ],
174
+ "collectionFormat": "pipes",
175
+ "format": ""
176
+ },
177
+ "allowEmptyValue": false
178
+ },
179
+ {
180
+ "name": "tqx",
181
+ "in": "query",
182
+ "description": "[Google Visualization API](https://developers.google.com/chart/interactive/docs/dev/implementing_data_source?hl=en) formatted parameter.",
183
+ "required": false,
184
+ "type": "string",
185
+ "allowEmptyValue": false
186
+ }
187
+ ],
188
+ "responses": {
189
+ "200": {
190
+ "description": "The call was successful. The response should include the data.",
191
+ "schema": {
192
+ "$ref": "#/definitions/chart"
193
+ }
194
+ },
195
+ "400": {
196
+ "description": "Bad request - the body will include a message stating what is wrong."
197
+ },
198
+ "404": {
199
+ "description": "No chart with the given id is found."
200
+ },
201
+ "500": {
202
+ "description": "Internal server error. This usually means the server is out of memory."
203
+ }
204
+ }
205
+ }
206
+ }
207
+ },
208
+ "definitions": {
209
+ "chart_summary": {
210
+ "type": "object",
211
+ "properties": {
212
+ "hostname": {
213
+ "type": "string",
214
+ "description": "The hostname of the netdata server."
215
+ },
216
+ "update_every": {
217
+ "type": "number",
218
+ "description": "The default update frequency of the netdata server. All charts have an update frequency equal or bigger than this."
219
+ },
220
+ "charts": {
221
+ "type": "object",
222
+ "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.",
223
+ "properties": {
224
+ "key": {
225
+ "$ref": "#/definitions/chart"
226
+ }
227
+ }
228
+ }
229
+ }
230
+ },
231
+ "chart": {
232
+ "type": "object",
233
+ "properties": {
234
+ "id": {
235
+ "type": "string",
236
+ "description": "The unique id of the chart"
237
+ },
238
+ "name": {
239
+ "type": "string",
240
+ "description": "The name of the chart"
241
+ },
242
+ "type": {
243
+ "type": "string",
244
+ "description": "The type of the chart. Types are not handled by netdata. You can use this field for anything you like."
245
+ },
246
+ "family": {
247
+ "type": "string",
248
+ "description": "The family of the chart. Families are not handled by netdata. You can use this field for anything you like."
249
+ },
250
+ "title": {
251
+ "type": "string",
252
+ "description": "The title of the chart."
253
+ },
254
+ "priority": {
255
+ "type": "string",
256
+ "description": "The relative priority of the chart. NetData does not care about priorities. This is just an indication of importance for the chart viewers to sort charts of higher priority (lower number) closer to the top. Priority sorting should only be used among charts of the same type or family."
257
+ },
258
+ "enabled": {
259
+ "type": "boolean",
260
+ "description": "True when the chart is enabled. Disabled charts do not currently collect values, but they may have historical values available."
261
+ },
262
+ "units": {
263
+ "type": "string",
264
+ "description": "The unit of measurement for the values of all dimensions of the chart."
265
+ },
266
+ "data_url": {
267
+ "type": "string",
268
+ "description": "The absolute path to get data values for this chart. You are expected to use this path as the base when constructing the URL to fetch data values for this chart."
269
+ },
270
+ "chart_type": {
271
+ "type": "string",
272
+ "description": "The chart type.",
273
+ "enum": [
274
+ "line",
275
+ "area",
276
+ "stacked"
277
+ ]
278
+ },
279
+ "duration": {
280
+ "type": "number",
281
+ "description": "The duration, in seconds, of the round robin database maintained by netdata."
282
+ },
283
+ "first_entry": {
284
+ "type": "number",
285
+ "description": "The UNIX timestamp of the first entry (the oldest) in the round robin database."
286
+ },
287
+ "last_entry": {
288
+ "type": "number",
289
+ "description": "The UNIX timestamp of the latest entry in the round robin database."
290
+ },
291
+ "update_every": {
292
+ "type": "number",
293
+ "description": "The update frequency of this chart, in seconds. One value every this amount of time is kept in the round robin database."
294
+ },
295
+ "dimensions": {
296
+ "description": "An object containing all the chart dimensions available for the chart. This is used as an indexed array. The key of the object the id of the dimension.",
297
+ "type": "object",
298
+ "properties": {
299
+ "key": {
300
+ "$ref": "#/definitions/dimension"
301
+ }
302
+ }
303
+ }
304
+ }
305
+ },
306
+ "dimension": {
307
+ "type": "object",
308
+ "properties": {
309
+ "name": {
310
+ "type": "string",
311
+ "description": "The name of the dimension"
312
+ }
313
+ }
314
+ }
315
+ }
316
+}
\ No newline at end of file
web/netdata-swagger.yaml
new
+207
@@ -0,0 +1,207 @@
1
+swagger: '2.0'
2
+info:
3
+ title: NetData API
4
+ description: 'Real time monitoring for linux, over the web!'
5
+ version: 1.0.0
6
+schemes:
7
+ - http
8
+basePath: /api/v1
9
+produces:
10
+ - application/json
11
+paths:
12
+ /charts:
13
+ get:
14
+ summary: 'Get a list of all charts available at the server'
15
+ description: 'The charts endpoint returns a summary about all charts stored in the netdata server.'
16
+ responses:
17
+ '200':
18
+ description: 'An array of charts'
19
+ schema:
20
+ type: array
21
+ items:
22
+ $ref: '#/definitions/chart_summary'
23
+ /chart:
24
+ get:
25
+ summary: 'Get info about a specific chart'
26
+ description: 'The Chart endpoint returns detailed information about a chart.'
27
+ parameters:
28
+ - name: chart
29
+ in: query
30
+ description: 'The id of the chart as returned by the /charts call.'
31
+ required: true
32
+ type: string
33
+ format: 'as returned by /charts'
34
+ responses:
35
+ '200':
36
+ description: 'A javascript object with detailed information about the chart.'
37
+ schema:
38
+ $ref: '#/definitions/chart'
39
+ '404':
40
+ description: 'No chart with the given id is found.'
41
+ /data:
42
+ get:
43
+ summary: 'Get collected data for a specific chart'
44
+ description: |
45
+ The Data endpoint returns data stored in the round robin database of a chart.
46
+ parameters:
47
+ - name: chart
48
+ in: query
49
+ description: 'The id of the chart as returned by the /charts call.'
50
+ required: true
51
+ type: string
52
+ format: 'as returned by /charts'
53
+ allowEmptyValue: false
54
+ - name: dimension
55
+ in: query
56
+ description: 'zero, one or more dimension ids, as returned by the /chart call.'
57
+ required: false
58
+ type: array
59
+ items:
60
+ type: string
61
+ collectionFormat: pipes
62
+ format: 'as returned by /charts'
63
+ allowEmptyValue: false
64
+ - name: after
65
+ in: query
66
+ description: 'This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
67
+ required: true
68
+ type: number
69
+ format: integer
70
+ allowEmptyValue: false
71
+ default: -600
72
+ - name: before
73
+ in: query
74
+ description: 'This parameter can either be an absolute timestamp specifying the ending point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
75
+ required: false
76
+ type: number
77
+ format: integer
78
+ allowEmptyValue: false
79
+ default: 0
80
+ - name: points
81
+ in: query
82
+ description: 'The number of points to be returned. If not given, or it is <= 0, or it is bigger than the points stored in the round robin database for this chart for the given duration, all the available collected values for the given duration are returned.'
83
+ required: true
84
+ type: number
85
+ format: integer
86
+ allowEmptyValue: false
87
+ default: 100
88
+ - name: group
89
+ in: query
90
+ description: 'The grouping method. If multiple collected values are to be grouped in order to return fewer points, this parameters defines the method of grouping. Two methods are supported, "max" and "average". "max" is actually calculated on the absolute value collected (so it works for both positive and negative dimesions to return the most extreme value in either direction).'
91
+ required: true
92
+ type: string
93
+ enum: [ 'max', 'average' ]
94
+ default: 'max'
95
+ allowEmptyValue: false
96
+ - name: format
97
+ in: query
98
+ description: 'The format of the data to be returned.'
99
+ required: true
100
+ type: string
101
+ enum: [ 'json', 'jsonp', 'csv', 'tsv', 'tsv-excel', 'ssv', 'ssvcomma', 'datatable', 'datasource', 'html', 'array' ]
102
+ default: json
103
+ allowEmptyValue: false
104
+ - name: options
105
+ in: query
106
+ description: 'Options that affect data generation.'
107
+ required: false
108
+ type: array
109
+ items:
110
+ type: string
111
+ enum: [ 'nonzero', 'flip', 'jsonwrap', 'min2max', 'seconds', 'milliseconds', 'abs', 'absolute', 'absolute-sum', 'null2zero', 'objectrows', 'google_json' ]
112
+ collectionFormat: pipes
113
+ format: ''
114
+ allowEmptyValue: false
115
+ - name: tqx
116
+ in: query
117
+ description: '[Google Visualization API](https://developers.google.com/chart/interactive/docs/dev/implementing_data_source?hl=en) formatted parameter.'
118
+ required: false
119
+ type: string
120
+ allowEmptyValue: false
121
+ responses:
122
+ '200':
123
+ description: 'The call was successful. The response should include the data.'
124
+ schema:
125
+ $ref: '#/definitions/chart'
126
+ '400':
127
+ description: 'Bad request - the body will include a message stating what is wrong.'
128
+ '404':
129
+ description: 'No chart with the given id is found.'
130
+ '500':
131
+ description: 'Internal server error. This usually means the server is out of memory.'
132
+definitions:
133
+ chart_summary:
134
+ type: object
135
+ properties:
136
+ hostname:
137
+ type: string
138
+ description: 'The hostname of the netdata server.'
139
+ update_every:
140
+ type: number
141
+ description: 'The default update frequency of the netdata server. All charts have an update frequency equal or bigger than this.'
142
+ charts:
143
+ type: object
144
+ 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.'
145
+ properties:
146
+ key:
147
+ $ref: '#/definitions/chart'
148
+ chart:
149
+ type: object
150
+ properties:
151
+ id:
152
+ type: string
153
+ description: 'The unique id of the chart'
154
+ name:
155
+ type: string
156
+ description: 'The name of the chart'
157
+ type:
158
+ type: string
159
+ description: 'The type of the chart. Types are not handled by netdata. You can use this field for anything you like.'
160
+ family:
161
+ type: string
162
+ description: 'The family of the chart. Families are not handled by netdata. You can use this field for anything you like.'
163
+ title:
164
+ type: string
165
+ description: 'The title of the chart.'
166
+ priority:
167
+ type: string
168
+ description: 'The relative priority of the chart. NetData does not care about priorities. This is just an indication of importance for the chart viewers to sort charts of higher priority (lower number) closer to the top. Priority sorting should only be used among charts of the same type or family.'
169
+ enabled:
170
+ type: boolean
171
+ description: 'True when the chart is enabled. Disabled charts do not currently collect values, but they may have historical values available.'
172
+ units:
173
+ type: string
174
+ description: 'The unit of measurement for the values of all dimensions of the chart.'
175
+ data_url:
176
+ type: string
177
+ description: 'The absolute path to get data values for this chart. You are expected to use this path as the base when constructing the URL to fetch data values for this chart.'
178
+ chart_type:
179
+ type: string
180
+ description: 'The chart type.'
181
+ enum: [ 'line', 'area', 'stacked' ]
182
+ duration:
183
+ type: number
184
+ description: 'The duration, in seconds, of the round robin database maintained by netdata.'
185
+ first_entry:
186
+ type: number
187
+ description: 'The UNIX timestamp of the first entry (the oldest) in the round robin database.'
188
+ last_entry:
189
+ type: number
190
+ description: 'The UNIX timestamp of the latest entry in the round robin database.'
191
+ update_every:
192
+ type: number
193
+ description: 'The update frequency of this chart, in seconds. One value every this amount of time is kept in the round robin database.'
194
+ dimensions:
195
+ description: 'The dimensions of the chart.'
196
+ type: object
197
+ description: 'An object containing all the chart dimensions available for the chart. This is used as an indexed array. The key of the object the id of the dimension.'
198
+ properties:
199
+ key:
200
+ $ref: '#/definitions/dimension'
201
+ dimension:
202
+ type: object
203
+ properties:
204
+ name:
205
+ type: string
206
+ description: 'The name of the dimension'
207
+