Skip to content

ProtoBuf

Jan Henrik H. Meling edited this page Mar 16, 2020 · 1 revision

Returning datapoints as protocol buffers

You can get datapoints in a more compact and faster to parse format by adding an accept header to your datapoints requests:

Accept: application/x-protobuf

The following .proto schema is used:

syntax = "proto3";

message CompactDatapointsDto {
   repeated CompactDatapointsItem data = 1;
   string continuationToken = 2;
}

message CompactDatapointsItem {
   string id = 1;
   uint64 totalCount = 2;
   repeated string fields = 3;
   repeated CompactDataPointValue values = 4;
}

message CompactDataPointValue {
   oneof value {
     int64 int64 = 1;
     double double = 2;
     uint32 uint32 = 3;
     uint64 uint64 = 4;
   }
}

The field names are specified once, and then the datapoints' values are serialized in a flat list next to eachother.

Non-aggregate requests will have time, value and status, in which case every three values will be the value of those fields and represent one datapoint.

The total count is the total number of datapoints the query results in, but not all of them will be returned if the datapoints limit is reached. In thoses cases, the number of returned datapoints is the number of values divided by the number of fields.

The time field is serialized as an unsigned 64-bit integer representing number of nanoseconds since unix epoch. In C# / .NET and can be parsed into a DateTime like this:

new DateTime(621355968000000000 + nanoseconds / 100, DateTimeKind.Utc);
Clone this wiki locally