FreifunkBremen / yanic

Yet another node info collector - for respondd to be used with meshviewer to Grafana (with influxdb or graphite)
https://freifunkbremen.github.io/yanic/
GNU Affero General Public License v3.0
20 stars 41 forks source link

[TASK] add output raw-jsonl #199

Closed lemoer closed 3 years ago

lemoer commented 3 years ago

Description

This output takes the respondd response as sent by the node and includes it in a Line-Delimited JSON (JSONL) document. In this format each line can be interpreted as separate JSON element, which is useful for json streaming. The first line is json object holding the timestamp and version of the file. Then there follows one line for each node, each containing a json object.

An example output looks like this:

{"version":1,"updated_at":"2021-03-27T21:58:48+0100","format":"raw-nodes-jsonl"}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
...

Signed-off-by: Leonardo Mörlein git@irrelefant.net

Motivation and Context

This is useful for json streaming.

Checklist:

genofire commented 3 years ago

I am a little bit confused about this PR - sorry, for the next question:


the PR looks really good:

so i am willing to merge it

lemoer commented 3 years ago

Regarding your questions:


Thanks for the feedback. The patches broke during rebase. Things are fixed now. I also found that my last commit (from another PR) had unclean go-fmt. That's why I added a patch for it here first, so that the tests pass.