-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager.asyncapi.yaml
868 lines (813 loc) Β· 27.1 KB
/
manager.asyncapi.yaml
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
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
# vim: set et ts=2 sw=2:
id: urn:rpc:metricq:manager
asyncapi: '2.0.0'
tags:
- name: "management"
description: >-
RPCs processed by management clients
- name: "direct"
description: >-
RPCs sent to a specific client directly
- name: "broadcast"
description: >-
RPCs sent to all clients on the network at once
- name: "source"
description: >-
RPCs used by Source instances
- name: "sink"
description: >-
RPCs used by Sink instances
- name: "transformer"
description: >-
RPCs used by Transformer instances
- name: "database"
description: >-
RPCs used by Database instances
- name: "history"
description: >-
RPCs used by history clients
info:
title: MetricQ Management Protocol
version: '0.1.0'
description: |
Clients on the MetricQ network are managed via an RPC protocol, where
messages are encoded in a JSON format.
A request consists of a JSON object with a property `"function"`, identifying
the action to perform.
Arguments are passed by specifying properties on the request object.
Replies are arbitrary JSON objects.
If a request could not be processed successfully, the reply has a single
property `"error"` containing an error message as a string.
RPCs are grouped into three categories and are tagged as such:
* **`management`**:
Management RPCs are sent to an exchange called `metricq.management`, management
clients subscribe to messages on this queue.
Replies from management clients arrive on a dedicated *management queue*.
* **`broadcast`**:
Broadcast RPCs are sent to an exchange called `metric.broadcast`.
All clients will receive such an request simultaneously and are expected to reply.
* **`direct`**:
Some RPCs are sent directly into a client's RPC queue, bypassing any exchange.
servers:
production:
url: "metricq.zih.tu-dresden.de"
protocol: ampq
defaultContentType: application/json
channels:
get_metrics:
description: >-
Query the network for available metrics
publish:
tags:
- name: "management"
message:
description: "Request information about available metrics"
bindings:
amqp:
replyTo:
type: string
correlationId:
location: $message.header#/correlation_id
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "get_metrics"
$ref: "#/components/schemas/rpcFunctionName"
format:
description: "Whether to return an array of metric names or an object mapping metric names to their metadata"
type: string
enum: ["array", "object"]
default: "array"
historic:
description: >-
If given, limit returned metrics to either historic (`true`) or non-historic (`false`) metrics.
If omitted, no filter is applied.
type: boolean
limit:
description: >-
Number of matched metrics to include in response.
If omitted, all matching metrics are returned.
type: integer
minimum: 0
hidden:
description: >-
If given, limit returned metrics to either hidden (`true`) or not hidden (`false`) metrics.
If omitted, this filter is not applied.
type: boolean
oneOf:
- properties:
selector:
$ref: "#/components/schemas/metricSelector"
- properties:
prefix:
type: string
description: "A prefix matching the start of a metric name"
examples:
- function: "get_metrics"
selector: "taurus\\.taurusi\\d{4}\\.cpu\\d\\+.power"
limit: 20
- function: "get_metrics"
prefix: "taurus"
historic: true
subscribe:
tags:
- name: "management"
message:
name: "get_metrics"
description: "A list of matching metrics, with optional metadata"
payload:
type: object
properties:
metrics:
$ref: "#/components/schemas/metricCollection"
get_configs:
description: >-
Retrieve the configuration object for a set of clients
publish:
tags:
- name: "management"
message:
name: "get_configs"
description: "Retrieve configuration objects for matching clients"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "get_configs"
$ref: "#/components/schemas/rpcFunctionName"
selector:
description: "A selector matching clients by their token"
oneOf:
- type: array
description: "A list of client tokens"
items:
type: string
- type: string
format: regex
description: "A regular expression matching a set of client tokens"
subscribe:
tags:
- name: "management"
message:
name: "get_configs"
description: "A mapping of client names to their configuration objects"
payload:
type: object
additionalProperties:
$ref: "#/components/schemas/configObject"
examples:
- "source-py-dummy":
rate: 0.5
sink.register:
description: >-
Register a new sink on the network
publish:
tags:
- name: "sink"
- name: "management"
message:
name: "sink.register"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "sink.register"
$ref: "#/components/schemas/rpcFunctionName"
examples:
- function: "sink.register"
subscribe:
tags:
- name: "sink"
- name: "management"
message:
name: "sink.register"
description: >-
On success, this contains the information necessary to start consuming metrics from the network.
Optionally, a configuration object for this sink is returned.
payload:
type: object
properties:
dataServerAddress:
$ref: "#/components/schemas/dataServerAddress"
config:
$ref: "#/components/schemas/configObject"
sink.subscribe:
description: >-
Request to receive data points for a set of metrics.
publish:
tags:
- name: "sink"
- name: "management"
message:
name: "sink.subscribe"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "sink.subscribe"
$ref: "#/components/schemas/rpcFunctionName"
metrics:
$ref: "#/components/schemas/metricList"
description: "A list of metrics to subscribe to."
dataQueue:
$ref: "#/components/schemas/dataQueue"
description: "The AMQP queue on which data points should arrive."
expires:
$ref: "#/components/schemas/seconds"
description: >-
The number of seconds after which the data queue should expire if not connected to a sink.
If omitted, a default value is set.
exclusiveMinimum: 0
metadata:
$ref: "#/components/schemas/metadataArgument"
required:
- "function"
- "metrics"
examples:
- function: "sink.subscribe"
metrics: ["building-F.room-A14.temperature.celcius"]
metadata: true
subscribe:
tags:
- name: "sink"
- name: "management"
message:
description: >-
After successful subscription, this contains the broker address and
queue on which data points for the requested metrics arrive.
The metrics in question are returned, optionally with their metadata attached.
payload:
$ref: "#/components/schemas/subscribeResponse"
sink.unsubscribe:
publish:
tags:
- name: "sink"
- name: "management"
message:
name: "sink.unsubscribe"
description: "Subscribe to receive data points for a set of metrics"
payload:
title: "sink.unsubscribe"
description: "Stop receiving data points for a set of metrics"
properties:
dataQueue:
$ref: "#/components/schemas/dataQueue"
description: >-
The AMQP queue at which data points should no longer be sent.
metrics:
$ref: "#/components/schemas/metricList"
end:
type: boolean
description: >-
If `true`, the manager sends a `type="end"` message after unbinding the routing keys to indicate that no more message will arrive at this queue.
default: true
required:
- "dataQueue"
- "metrics"
subscribe:
tags:
- name: "sink"
- name: "management"
message:
description: >-
An acknowledgement of unsubscription
payload:
type: object
properties:
dataServerAddress:
$ref: "#/components/schemas/dataServerAddress"
metrics:
description: "The collection of metrics this client is no longer subscribed to"
$ref: "#/components/schemas/metricCollection"
sink.release:
publish:
tags:
- name: "sink"
- name: "management"
message:
name: "sink.release"
title: "sink.release"
description: "Release a data queue"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "sink.release"
$ref: "#/components/schemas/rpcFunctionName"
dataQueue:
$ref: "#/components/schemas/dataQueue"
description: "The data queue to be released"
subscribe:
tags:
- name: "sink"
- name: "management"
message:
payload:
type: object
description: "Acknowledgement of successful release"
source.register:
publish:
tags:
- name: "source"
- name: "management"
message:
name: "source.register"
summary: "Register a source on the network"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "source.register"
$ref: "#/components/schemas/rpcFunctionName"
subscribe:
tags:
- name: "source"
- name: "management"
message:
payload:
type: object
properties:
dataServerAddress:
$ref: "#/components/schemas/dataServerAddress"
dataExchange:
$ref: "#/components/schemas/dataExchange"
config:
$ref: "#/components/schemas/configObject"
source.declare_metrics:
publish:
tags:
- name: "source"
- name: "management"
message:
name: "source.declare_metrics"
summary: "Declare a list of metrics which this source provides"
payload:
type: object
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "source.declare_metrics"
$ref: "#/components/schemas/rpcFunctionName"
metrics:
$ref: "#/components/schemas/metricCollection"
required:
- "metrics"
subscribe:
tags:
- name: "source"
- name: "management"
message:
payload:
$ref: "#/components/schemas/declareMetricsResponse"
transformer.register:
publish:
tags:
- name: "transformer"
- name: "management"
message:
name: "transformer.register"
summary: "Register a transformer on the network"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "transformer.register"
$ref: "#/components/schemas/rpcFunctionName"
subscribe:
tags:
- name: "transformer"
- name: "management"
message:
payload:
type: object
properties:
dataExchange:
$ref: "#/components/schemas/dataExchange"
config:
$ref: "#/components/schemas/configObject"
transformer.declare_metrics:
publish:
tags:
- name: "transformer"
- name: "management"
message:
name: "transformer.declare_metrics"
summary: "Declare a list of metrics which this transformer provides"
payload:
type: object
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "transformer.declare_metrics"
$ref: "#/components/schemas/rpcFunctionName"
metrics:
$ref: "#/components/schemas/metricCollection"
required:
- "metrics"
subscribe:
tags:
- name: "transformer"
- name: "management"
message:
payload:
$ref: "#/components/schemas/declareMetricsResponse"
transformer.subscribe:
publish:
tags:
- name: "transformer"
- name: "management"
message:
name: "transformer.subscribe"
title: "transformer.subscribe"
description: "Subscribe to receive data points for a set of metrics"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "transformer.subscribe"
$ref: "#/components/schemas/rpcFunctionName"
metrics:
$ref: "#/components/schemas/metricList"
metadata:
$ref: "#/components/schemas/metadataArgument"
required:
- "function"
- "metrics"
subscribe:
tags:
- name: "transformer"
- name: "management"
message:
title: "transformer.subscribe"
description: >-
`transformer.subscribe` response
payload:
$ref: "#/components/schemas/subscribeResponse"
db.register:
description: >-
Register a database on the network.
publish:
tags:
- name: "database"
- name: "management"
message:
name: "db.register"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "db.register"
$ref: "#/components/schemas/rpcFunctionName"
subscribe:
tags:
- name: "database"
- name: "management"
message:
payload:
type: object
properties:
dataServerAddress:
$ref: "#/components/schemas/dataServerAddress"
dataExchange:
$ref: "#/components/schemas/dataExchange"
dataQueue:
$ref: "#/components/schemas/dataQueue"
description: "Metrics to be saved in the DB arrive on this queue"
historyQueue:
$ref: "#/components/schemas/historyQueue"
config:
$ref: "#/components/schemas/configObject"
db.subscribe:
description: >-
Request to receive data points for metrics to be saved in the DB.
publish:
tags:
- name: "database"
- name: "management"
message:
name: "db.subscribe"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "db.subscribe"
$ref: "#/components/schemas/rpcFunctionName"
metrics:
description: >-
A list of metrics to save, possibly with custom names for history requests.
oneOf:
- type: array
description: "A list of metrics to save in the DB"
items:
$ref: "#/components/schemas/metricName"
- type: array
description: >-
A list of metrics to save, with custom names for history requests.
Queue bindings for the `dataQueue` will use `input`,
while queue bindings for the `historyQueue` will use `name`.
items:
type: object
properties:
name:
$ref: "#/components/schemas/metricName"
input:
$ref: "#/components/schemas/metricName"
required:
- name
- input
metadata:
$ref: "#/components/schemas/metadataArgument"
required:
- "function"
- "metrics"
examples:
- function: "db.subscribe"
metrics: ["building-F.room-A14.temperature.celcius"]
metadata: true
- function: "db.subscribe"
metrics:
- name: "history-name.foo-metric"
input: "test.foo-metric"
subscribe:
tags:
- name: "database"
- name: "management"
message:
description: >-
After successful subscription, this contains the broker address and
queue on which data points for the requested metrics arrive.
The metrics in question are returned, optionally with their metadata attached.
payload:
$ref: "#/components/schemas/subscribeResponse"
history.register:
description: >-
Register a history client on the network.
publish:
tags:
- name: "history"
- name: "management"
message:
name: "history.register"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "history.register"
$ref: "#/components/schemas/rpcFunctionName"
subscribe:
tags:
- name: "history"
- name: "management"
message:
payload:
type: object
properties:
dataServerAddress:
$ref: "#/components/schemas/dataServerAddress"
historyExchange:
type: string
examples:
- "metricq.history"
historyQueue:
$ref: "#/components/schemas/historyQueue"
config:
$ref: "#/components/schemas/configObject"
discover:
publish:
tags:
- name: "broadcast"
message:
name: "discover"
summary: "A discovery request sent to all clients online"
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "discover"
$ref: "#/components/schemas/rpcFunctionName"
subscribe:
tags:
- name: "broadcast"
message:
name: "discover"
summary: "A discovery response including operational information of a client"
payload:
properties:
alive:
type: boolean
default: true
currentTime:
type: string
format: date-time
description: "Current time on this host"
startingTime:
type: string
format: date-time
description: "When this client was started and first connected to the network"
uptime:
type: integer
format: nanoseconds
description: >-
Number of nanoseconds since startup of this client.
If missing, assume this is the difference between `currentTime` and `startingTime`.
metricqVersion:
type: string
description: >-
The version of the MetricQ client library that this client uses to communicate with the network.
This value is intended for human consumption and its format should not be relied opon.
Nonetheless, a format of _<library-name>/<version>_ is encouraged.
examples:
- "metricq-python/1.1.4"
- "metricq-cpp/r501.ge944379"
pythonVersion:
type: string
description: >-
The version of the running Python interpreter, if the client uses the MetricQ Python bindings.
examples:
- "3.9.2"
hostname:
type: string
description: >-
The hostname identifying the machine that this client runs on.
examples:
- "bahka"
- "192.0.2.42"
config:
publish:
tags:
- name: "direct"
message:
name: "config"
summary: >-
Provide an updated configuration object to a client
payload:
$ref: "#/components/schemas/rpcFunction"
properties:
function:
const: "config"
$ref: "#/components/schemas/rpcFunctionName"
additionalProperties: true
subscribe:
tags:
- name: "direct"
message:
name: "config"
summary: >-
Configuration acknowledgement
payload:
type: object
description: "Acknowledgement that configuration has been received successfully"
components:
schemas:
rpcFunction:
type: object
properties:
function:
$ref: "#/components/schemas/rpcFunctionName"
required:
- "function"
rpcFunctionName:
type: string
title: "RPC function name"
description: "A string identifying the requested RPC function"
pattern: "([a-z_]+\\.)+[a-z_]+"
metricName:
type: string
pattern: "([a-zA-Z][a-zA-Z0-9_]+\\.)+[a-zA-Z][a-zA-Z0-9_]+"
examples:
- "elab.bahka.power"
- "elab.ariel.package0.dram.current"
- "taurus.taurusi4101.cpu0.power"
metricList:
type: array
description: "A list of metric names"
items:
$ref: "#/components/schemas/metricName"
uniqueItems: true
metricsWithMetadata:
type: object
description: "A mapping of metric names to metadata objects"
additionalProperties:
$ref: "#/components/schemas/metadata"
examples:
- elab.bahka.power:
rate: 20
scope: "last"
unit: "W"
metricCollection:
description: "A collection of metric names, with optional metadata attached"
oneOf:
- $ref: "#/components/schemas/metricList"
- $ref: "#/components/schemas/metricsWithMetadata"
metricSelector:
description: "A selector matching a set of metrics, either by regex or explicit listing"
oneOf:
- type: string
format: regex
description: "A regular expression matching a set of metric names"
examples:
- "taurus\\.taurusi\\d{4}\\.cpu\\d\\+.power"
- $ref: "#/components/schemas/metricList"
dataQueue:
type: string
format: "uri"
examples:
- "amqp://user:pass@localhost/vhost"
- "amqps://metricq.example.com:50505/"
historyQueue:
type: string
format: "uri"
description: "Requests for historic data arrive on this queue"
examples:
- "amqp://user:pass@localhost/history"
- "amqps://metricq.example.com:50505/"
seconds:
type: number
format: seconds
metadata:
description: "A metadata object"
type: object
properties:
unit:
type: string
title: "Unit symbol"
description: >-
The unit symbol according to SI, such as `"V"` for voltage or `"s"` for time.
If necessary, the SI prefix is included, e.g. `"kV"`, `"ms"`, or `"kiB/s"`.
_Dimensionless_ quantities such as counts use either an empty string (`""`) or the appropriate symbol (e.g. "rad").
examples:
- "V"
- "kV"
- "s"
- "kiB/s"
- "rad"
- ""
rate:
type: integer
description: >-
The rate in `Sa/s` (samples per second) or `Hz` at which new values of this metric are typically produced.
In practice, a source does not necessarily need to produce values exactly at this rate, but the value given should be good estimate.
scope:
enum: ["last", "next", "point"]
description: >-
The temporal validity of a single measured value.
A scope of `"last"` indicates that a measured value was valid _up to now_, `"next"` that it is valid _from now on_.
A scope of `"point"` means that any measurement is only valid at exactly the moment it was taken.
quantity:
type: string
description: >-
The name of the measured quantity.
Ideally, this is the same as the last segment of the metric name.
examples:
- "power"
- "temperature"
description:
type: string
description: >-
A human-readable description of the measurement quantity
examples:
- rate: 0.1
configObject:
description: "A client configuration object"
type: object
examples:
- reportNeighboursDogActivity: true
metricSourceChannels:
"kittens.front-flap.opened.count": "automation.doors.front.catflap.triggered#cumulative"
"kittens.water-bowl.1.volume": "automation.volume-sensors[5]"
- clientSpecificOption: 42
monitorKittenHealth: true
dataServerAddress:
type: string
format: url
description: "URL pointing to the AMQP broker where data queues are handled"
examples:
- "amqp://user:pass@localhost/data-vhost"
- "amqps://metricq.example.com:50505/"
dataExchange:
type: string
description: "Name of the exchange to which data points should be published"
examples:
- "metricq.data"
declareMetricsResponse:
type: object
description: "Acknowledgement that metrics have been declared successfully"
metadataArgument:
type: boolean
default: false
description: >-
Whether to include metadata for each metric in the reponse.
If set to `false`, the result is an array of metric names,
if set to `true`, an object mapping metric names to metadata objects is returned.
subscribeResponse:
type: object
properties:
dataServerAddress:
$ref: "#/components/schemas/dataServerAddress"
dataQueue:
$ref: "#/components/schemas/dataQueue"
description: >-
The AMQP queue at which data points for the subscribed metrics will arrive.
metrics:
$ref: "#/components/schemas/metricCollection"