-
Notifications
You must be signed in to change notification settings - Fork 2
/
api.yml
822 lines (804 loc) · 24 KB
/
api.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
# Status Site API
swagger: '2.0'
info:
title: Status Site API
description: |
Collects, processes and provides various data regarding the status of
the services.
version: "1.0.0"
host: status.dbogatov.org
securityDefinitions:
apiauth:
type: apiKey
description: |
The API key needed for authentication and authorization.
name: apikey
in: header
userauth:
type: basic
authorizationUrl: /account/login
description: |
Cookie based authorization.
User should login here: `/account/login` and upon successful login the cookie is returned.
schemes:
- https
- http
basePath: /api
produces:
- application/json
- text/plain
paths:
/cpuload:
post:
summary: CPU Load data
description: |
CPU Load endpoint collects data regarding CPU load from different
sources. Particularly, a single number, CPU load percentage is expected.
consumes:
- application/x-www-form-urlencoded
produces:
- text/plain
parameters:
- name: value
in: formData
description: Value of CPU load, percentage
required: true
type: integer
format: int32
example: 25
- &SOURCE_PARAM
name: source
in: formData
description: |
The source of data.
Should uniquely represent the entity which sends the data.
For example, server identifier or website URL.
Has to satisfy regexp `[a-z0-9\\.\\-]+` and be no more than 32 characters long.
required: true
type: string
format: string
example: "the-server"
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
&401
description: Unauthorized. API Key is invalid or missing.
400:
&400
description: Bad Request. One or more parameters are invalid or missing.
200:
&200
description: OK. The data has been saved.
default:
&500
description: Internal server error (500)
/compilation:
post:
summary: Compilation stage completion report
description: |
Compilation endpoint collects data regarding completed compilations from different
sources. Particularly, source size, compilation time for a particular stage are expected.
consumes:
- application/x-www-form-urlencoded
produces:
- text/plain
parameters:
- name: stage
in: formData
description: Compilation stage completed
required: true
type: string
format: string
enum:
- "m4"
- "sandpiper"
- "simulation"
example: "m4"
- name: sourcesize
in: formData
description: Size of the source code in bytes
required: true
type: number
format: int32
example: "512256"
- name: compiletime
in: formData
description: Time spent for compilation stage in milliseconds
required: true
type: number
format: int32
example: "659"
- <<: *SOURCE_PARAM
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
<<: *401
400:
<<: *400
200:
<<: *200
default:
<<: *500
/logdata:
post:
summary: Report number and severity of generated log messages
description: |
Log Data endpoint collects data regarding log messages generated by different
sources. Particularly, message severity and count are expected.
consumes:
- application/x-www-form-urlencoded
produces:
- text/plain
parameters:
- &SEVERITY_PARAM
name: severity
in: formData
description: Message severity
required: true
type: string
format: string
enum:
- "debug"
- "detail"
- "user"
- "info"
- "warn"
- "error"
- "fatal"
example: "debug"
- name: count
in: formData
description: Number of message of given severity generated
required: false
default: 1
type: number
format: int32
example: 6
- <<: *SOURCE_PARAM
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
<<: *401
400:
<<: *400
200:
description: OK. The data has been saved.
default:
description: Internal server error (500)
/logmessage:
post:
summary: Record a log message
description: |
Log Message endpoint collects log messages of different severities from different sources.
consumes:
- application/x-www-form-urlencoded
produces:
- text/plain
parameters:
- <<: *SEVERITY_PARAM
- name: auxiliarydata
in: formData
description: |
Additional data, like metadata, not required for the log message.
If provided, must be in a JSON format.
required: false
default: ""
type: string
format: string
example: |
{
"Exception": "Cannot bind to port 80. Address already in use."
}
- name: message
in: formData
description: A message part of the log entry.
required: true
type: string
format: string
example: User with id 4568 has created a project with id 6868.
- name: category
in: formData
description: |
An integer representing a category (or type) of the log entry.
Categorization is scoped and is up to the source.
required: false
default: 0
type: number
format: int32
example: 6
- <<: *SOURCE_PARAM
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
<<: *401
400:
<<: *400
200:
<<: *200
default:
<<: *500
/useraction:
post:
summary: User action report
description: |
User action enpoint collects data regarding user actions performed on different
sources. Particularly, user action and count are recorded.
consumes:
- application/x-www-form-urlencoded
produces:
- text/plain
parameters:
- name: action
in: formData
description: |
User Action as a string.
<b>Note:</b> be consistent, "user-login" and "user login" will be considered different actions.
required: true
type: string
format: string
example: "login"
- name: count
in: formData
description: Number of times given action was performed
required: false
default: 1
type: number
format: int32
example: "6"
- <<: *SOURCE_PARAM
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
<<: *401
400:
<<: *400
200:
<<: *200
default:
<<: *500
/getdata:
get:
summary: Retrieve status data
description: |
Get Data endpoint returns all available data that matches parameters.
parameters:
- &METRICTYPE_PARAM
name: metrictype
in: query
description: |
Metric type for which data is requested.
required: true
type: string
format: string
enum:
- "cpuload"
- "useraction"
- "compilation"
- "log"
- "ping"
example: "cpuload"
- <<: *SOURCE_PARAM
in: query
- name: timeperiod
in: query
description: |
Number of seconds ago from which data is requested.
Default value is roughly a month.
required: false
default: 2592000
type: integer
fomat: int32
example: 604800
responses:
401:
<<: *401
400:
<<: *400
404:
description: |
Not Found. The metric of given type (CPU load) and source does not
exist.
200:
description: OK. The data points are retrieved.
schema:
type: array
items:
$ref: '#/definitions/DataPoint'
example:
&DATAPOINT_EXAMPLE
- timestamp: "2017-01-27T11:30:40.510739-05:00"
value: 65
- timestamp: "2017-01-27T11:30:40.510739-05:00"
severity: "fatal"
count: 5
- timestamp: "2017-01-27T11:30:40.510739-05:00"
severity: "login"
count: 6
- timestamp: "2017-01-27T11:30:40.510739-05:00"
compiletime: 65482
sourcesize: 4984634
stage: "m4"
- timestamp: "2017-01-27T11:30:40.510739-05:00"
responsetime: 522
httpstatuscode: 200
204:
&204
description: |
No Content. No errors are encountered and there are no data points
matching given criteria.
default:
<<: *500
/health:
get:
summary: Get overall system health
description: |
Health endpoint returns the object that describes health of the system.
responses:
200:
description: OK. The health report is retrieved.
schema:
$ref: '#/definitions/HealthReport'
example:
&HEALTH_REPORT_EXAMPLES
- timestamp: "2017-01-27T11:30:40.510739-05:00"
health: 95
data:
&HEALTH_REPORT_DP_EXAMPLES
- type: cpuload
source: the-source
label: normal
- type: useraction
source: the-source
label: warning
204:
&204
description: |
No Content. No errors are encountered and there are no data points
matching given criteria.
default:
<<: *500
/getmetrics:
get:
summary: Retrieve available metrics
description: |
Get Metrics endpoint returns available metrics (optionally filtered
by source and/or type parameters) which include metadata (eq. title)
and numeric data (day-, hour- average, min, max, current value).
<b>Note:</b> current value is always up-to-date (regardless of last
updated value).
parameters:
- <<: *METRICTYPE_PARAM
required: false
- <<: *SOURCE_PARAM
required: false
in: query
responses:
401:
<<: *401
200:
description: OK. The metrics are retrieved.
schema:
type: array
items:
$ref: '#/definitions/Metric'
example:
&METRIC_EXAMPLES
- source: "http://makerchip.com"
title: "Web service response time"
autolabel:
&LABEL_EXAMPLE_1
title: Minor degradation
severity: warning
manuallabel:
&LABEL_EXAMPLE_2
title: We are investigating
severity: investigating
daymin: 100
daymax: 500
dayavg: 300
hourmin: 150
hourmax: 400
houravg: 200
currentvalue: 350
lastupdated: "2017-01-27T11:30:40.510739-05:00"
- source: "compilation-server-13"
title: "CPU Load"
autolabel:
&LABEL_EXAMPLE_3
title: Normal operation
severity: normal
manuallabel:
&LABEL_EXAMPLE_4
title: ""
severity: none
daymin: 1
daymax: 70
dayavg: 25
hourmin: 1
hourmax: 30
houravg: 20
currentvalue: 15
lastupdated: "2017-01-27T11:30:45.510739-05:00"
204:
<<: *204
default:
<<: *500
/getlogmessages:
get:
summary: Retrieve available log messages
description: |
Get Log Messages endpoint returns all available log messages.
parameters:
- name: sources
in: query
description: |
Coma separated collection of source names used to filter log messages.
If not provided, log messages will not be filtered by source.
required: false
default: ""
type: string
fomat: string
example: "source-1,source-2"
- name: categories
in: query
description: |
Coma separated collection of categories used to filter log messages.
If not provided, log messages will not be filtered by category.
required: false
default: ""
type: string
fomat: string
example: "1,2"
- name: severities
in: query
description: |
Coma separated collection of severities used to filter log messages.
If not provided, log messages will not be filtered by severity.
List of severities is the same as input enumeration for "logmessage" endpoint.
required: false
default: ""
type: string
fomat: string
example: "info,warn"
- name: keywords
in: query
description: |
Coma separated collection of words used to filter log messages.
If not provided, log messages will not be filtered by keywords.
Log message body and auxillary data will be searched for keywords.
If and only if any keyword exists in log message, the message will be included in the output.
Keywords may not contain white spaces.
required: false
default: ""
type: string
fomat: string
example: "user,login"
- name: start
in: query
description: |
Date and time from which to include log messages.
Timestamp is formatted as the number of milliseconds since Jan 1, 1970.
If not provided, log messages will not be filtered by start date.
required: false
default: ""
type: string
fomat: string
example: "1494440378000"
- name: end
in: query
description: |
Date and time to which to include log messages.
Timestamp is formatted as the number of milliseconds since Jan 1, 1970.
If not provided, log messages will not be filtered by end date.
required: false
default: ""
type: string
fomat: string
example: "1494440378000"
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
<<: *401
200:
description: OK. The log messages are retrieved.
schema:
type: array
items:
$ref: '#/definitions/LogMessage'
example:
&LOGMESSAGE_EXAMPLES
- source: compilation-server-13
id: 4564
message: User with id 4568 has created a project with id 6868.
auxiliarydata: ""
severity: "Information"
category: 5
timestamp: "2017-01-27T11:30:40.510739-05:00"
- source: http-server-15
id: 1002
message: Server startup failed.
auxiliarydata: |
{
"Exception": "Cannot bind to port 80. Address already in use."
}
severity: "Fatal error"
category: 6
timestamp: "2017-01-27T11:30:45.510739-05:00"
204:
<<: *204
default:
<<: *500
/removemetric:
delete:
summary: Remove a metric
description: |
Remove Metric endpoint removes a metric from the system.
produces:
- text/plain
parameters:
- <<: *METRICTYPE_PARAM
- <<: *SOURCE_PARAM
in: query
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
<<: *401
400:
<<: *400
404:
description: |
Not Found. The metric of given type and source does not
exist.
200:
description: OK. The metric has been removed.
default:
<<: *500
/metricupdate:
patch:
summary: Modify a metric
description: |
Metric Update endpoint changes the existing metric in the system.
consumes:
- application/x-www-form-urlencoded
produces:
- text/plain
parameters:
- <<: *METRICTYPE_PARAM
in: formData
- <<: *SOURCE_PARAM
- name: manuallabelid
in: formData
description: |
An ID of the manual label to set for the metric.
required: true
type: integer
fomat: int32
example: "2"
- name: public
in: formData
description: |
A boolean indicating if the metric should be public or not.
Tru for public, false for private.
required: true
type: boolean
example: "true"
security:
- apiauth: ["status"]
- userauth: ["status"]
responses:
401:
<<: *401
400:
<<: *400
404:
description: |
Not Found. The metric of given type and source does not
exist. Or the manual label of given ID does not exist.
200:
description: OK. The metric has been updated.
default:
<<: *500
definitions:
LogMessage:
type: object
required:
- source
- id
- message
- auxiliarydata
- severity
- category
- timestamp
properties:
source:
type: string
description: The source of the metric (eq. server identifier or url)
timestamp:
type: string
description: Timestamp when log entry was recorded.
id:
type: number
description: Unique identifier for the log entry.
message:
type: string
description: A message part of the log entry.
auxiliarydata:
type: string
description: |
Additional data, like metadata, not required for the log message.
Given in a JSON format.
severity:
type: string
description: Log entry severity (eq. warn or error)
category:
type: number
description: |
An integer representing a category (or type) of the log entry.
Categorization is scoped and is up to the source.
example:
*LOGMESSAGE_EXAMPLES
Label:
type: object
required:
- title
- severity
properties:
title:
type: string
description: text part of the label
severity:
type: string
description: string representation of severity of the label
example:
- <<: *LABEL_EXAMPLE_1
- <<: *LABEL_EXAMPLE_2
- <<: *LABEL_EXAMPLE_3
- <<: *LABEL_EXAMPLE_4
Metric:
type: object
required:
- source
- title
- autolabel
- manuallabel
- daymin
- daymax
- dayavg
- hourmin
- hourmax
- houravg
- currentvalue
properties:
source:
type: string
description: The source of the metric (eq. server identifier or url)
title:
type: string
description: Human readable title of the metric (eq. CPU Load).
autolabel:
type: Label
description: The label assigned to the metric automatically by the system (eq. Normal operation)
manuallabel:
type: Label
description: The label assigned to the metric manually by the administrator (eq. We are investigating the issue)
daymin:
type: number
description: The lowest numberic value of the metric in a timerange from now to a day ago
daymax:
type: number
description: The highest numberic value of the metric in a timerange from now to a day ago
dayavg:
type: number
description: The average of the numberic values of the metric in a timerange from now to a day ago
hourmin:
type: number
description: The lowest numberic value of the metric in a timerange from now to an hour ago
hourmax:
type: number
description: The highest numberic value of the metric in a timerange from now to an hour ago
houravg:
type: number
description: The average of the numberic values of the metric in a timerange from now to an hour ago
currentvalue:
type: number
description: The most recent value of the metric
lastupdated:
type: string
description: |
Timestamp when metric values (except currentvalue) were updated.
currentvalue is always up to date.
example:
*METRIC_EXAMPLES
HealthReport:
type: object
required:
- timestamp
- health
- data
properties:
timestamp:
type: string
description: |
Timestamp when this report was generated.
May not be eqaul to current timestamp.
Reports are generated periodically and are cached.
health:
type: integer
description: Health value (percent).
data:
type: array
description: List of HealthReportDataPoint.
items:
$ref: "#/definitions/HealthReportDataPoint"
example:
*HEALTH_REPORT_EXAMPLES
HealthReportDataPoint:
type: object
required:
- type
- source
- label
properties:
type:
type: string
description: Metric type (eq. cpuload)
source:
type: string
description: Metric source
label:
type: string
description: Metric label (eq. normal)
example:
*HEALTH_REPORT_DP_EXAMPLES
DataPoint:
# Wanted oneOf thing, but here is the PR: https://github.com/OAI/OpenAPI-Specification/pull/741
type: object
required:
- timestamp
properties:
timestamp:
type: string
description: Timestamp when data point was recorded.
value:
type: integer
description: The value of a **numeric** data point.
severity:
type: string
description: The severity of a log message in a **log** data point.
count:
type: number
description: The number of items in a **log** or **useraction** data point.
useraction:
type: string
description: The action performed by user in a **useraction** data point.
compiletime:
type: number
description: The number of milliseconds taken for compilation in a **compilation** data point.
sourcesize:
type: number
description: The size of the source file in bytes in a **compilation** data point.
stage:
type: string
description: The compilation stage in a **compilation** data point.
responsetime:
type: number
description: The response time in milliseconds in a **ping** data point.
httpstatuscode:
type: number
description: The status code of a response in a **ping** data point.
example:
*DATAPOINT_EXAMPLE