The metrics-exporter-scope communication protocol is a TCP protocol to exchange metrics between the server process and clients.
The default port is 5001
.
The serialization format is a MessagePack.
-
After the connection is established, the server writes 2-byte VERSION packet, which contains the protocol version, encoded in little-endian. If the client does not support the protocol version, it should close the connection.
-
The client sends serialized
ClientSettings
structure:
{
"sampling_interval": 1000000
}
where
sampling_interval
is the interval the server thread should sample the metrics and send them to the client. The interval is specified in nanoseconds.
The server sends serialized metrics snapshot packets as well as information ones to the client. The first packet is always an information one. The client should determine the packet type according to its structure.
The information packets are used to send metrics metadata to the client. The server sends such packets every 5 seconds (by default).
{
"metrics": {
"metric_name": {
"labels": {
"label_name": "label_value",
"label_name2": "label_value2"
}
},
"metric_name2": {
"labels": {
"label_name": "label_value",
"label_name2": "label_value2"
}
}
}
}
The client may use metrics labels as hints for displaying the data. The default labels are:
-
plot
group several metrics into a single plot -
color
specify the color of the line in the plot
The snapshot packets contain the actual metrics data. The server sends such
using the sampling interval, specified during Chat
phase.
{
"t": 1234567890,
"d": {
"metric_name": 123.4,
"metric_name2": 456.7
}
}
where
-
t
is the timestamp of the snapshot, in nanoseconds. The timestamp is monotonic and relative to the time point theCommunication
phase started at. -
d
is the dictionary of metrics. The keys are metric names, and the values are float numbers.
The payload always contains state of all metrics at the moment of the snapshot, despite the metrics have been changed or not.