mallinfo to LightDB Stream
The Struct-to-JSON transformer can be used to convert structured binary data, such as that created by packed C structs, into JSON, according to a user provided schema. Sending structured binary data from the device is particularly suited to cases where bandwidth is severely constrained, the data is in a well-defined standard format, or the structure of the data is unlikely to change.
This example demonstrates converting data returned by a call to mallinfo2()
on a 64-bit Linux
system into JSON for ingestion into LightDB Stream, where the data can be
analyzed to assess dynamic memory usage of the program. As the data returned by
mallinfo2()
is both well-defined and unlikely to change structure, this data
is a good candidate for sending as structured binary data, saving bandwidth and
CPU cycles on the embedded device.
filter:
path: "/mallinfo"
content_type: application/octet-stream
steps:
- name: step0
transformer:
type: struct-to-json
version: v1
parameters:
members:
- name: arena
type: u64
- name: ordblks
type: u64
- name: smblks
type: u64
- name: hblks
type: u64
- name: hblkhd
type: u64
- name: usmblks
type: u64
- name: fsmblks
type: u64
- name: uordblks
type: u64
- name: fordblks
type: u64
- name: keepcost
type: u64
destination:
type: lightdb-stream
version: v1