-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submit bulk measurements with timestamps using specialized "bulk-json-compact" format #39
Comments
Dear Valentin, thanks for writing in and for sharing the payload format you are trying to ingest. I will try to answer as good as possible. Measurements with timestamps
Indeed, Kotori can accept timestamped measurements, see [1]. I have been able to find this back by searching for "timestamp" within the documentation, like [2]. Please let us know how we might be able to improve the discoverability of that feature within the documentation. However, Kotori currently needs those timestamps to be inlined into the distinct measurement payloads, like {
"time": 1611082554,
"temperature": 45.2
} Kotori also accepts timestamps within other fields, like Bulk readings (vanilla)
Unfortunately, Kotori is currently not able to accept bulk readings yet. We already planned to implement that but haven't been able to catch up with it. Regarding our plans, we would have implemented it to make Kotori accept payloads like that: [
{
"time": 1611082554,
"temperature": 45.2
},
{
"time": 1611082568,
"temperature": 45.3
}
] Bulk readings (specialized decoder)
Now that you showed us the payload format you are trying to ingest, I would like to comment on that. It feels a bit weird to transfer the Unix Timestamp as a string and at the same time use it as a key. But okay, that's how reality looks like, right? Kotori might implement that as a specialized decoder like the Tasmota decoder [4] we added the other day and I am open to that in general. However, I am curious where this payload is coming from and want to humbly ask if you can share some more information about this? {
"1611082554": {
"temperature": 45.2
},
"1611082568": {
"temperature": 45.3
}
} Thanks again for sharing your use case. Depending on your time frame and your response, we might be able to do something about it within the next development iteration. With kind regards, [1] https://getkotori.org/docs/handbook/acquisition/timestamp.html |
Hello, thank you for your extensive response. I hadn't seen the option of using my own timestamp in every measure, maybe with that I could do something (extracting each measure from the original message and sending it individually to Kotori). The format of the measures we use is simply intended to reduce the size of the messages. We are working with a device that must read a large amount of data from a vehicle and transmit it using a limited number of bytes per message. With this format we avoid sending a "time" key or similar in each value, which allows us to save a lot of space even keeping the values readable by humans. After reading your comment about a future implementation of bulk readings I think there would be another problem in our case. Although in the example I gave the two measurements were the same (temperature), actually each of the individual measurements may include different values (e.g. one is a temperature value but the other is a humidity value). I understand that this is a quite particular case, so I don't think that introducing it as a functionality in Kotori could be something that the community could take advantage of. It would be, in my opinion, the fact of having an API or mechanism to create a custom decoder. This way we could process our "special" message and generate an array of values in the format expected by Kotori. For now I think I will prepare a mqtt subscriber to extract the measurements of each message and publish them again in other different topics for Kotori to process. As in our case it is not necessary to work in real time, the small delay that could be introduced with this pre-processing will not affect us. Thanks again for your answers and for keeping the project active. |
Hi Valentin,
I see. Thanks for your insights. Maybe you shouldn't be using JSON at all if you have hard requirements on message sizes? However, I well recognize the feature of human readability of telemetry packets on the wire. We tried to balance similar aspects when conceiving BERadio the other day and, well, while it's still ASCII, it's not that much human readable in comparison to JSON. We even wrote up a summary about serialization efficiency wrt. payload size of different marshalling formats. So, I hear you.
That would be an option, but you would have to run another software component side by side. I am absolutely not against supporting specific use cases for users of Kotori (you! ;]) - so thanks for outlining your scenario.
Exactly. However, currently even the Tasmota decoder mentioned above is built-in and the payload format will be detected by applying some heuristics. As long as the number of different payload formats will not be overwhelmingly high, we might well keep it like that. As soon as there is a need for it, we will think about implementing a real plugin/extension subsystem for being able to hook custom external decoders into the stream.
I am not sure I am following here. Having readings of multiple sensors within individual measurement containers is well supported and this is what we actually already recommend when ingesting single (non-bulk) measurements. The rationale behind this is that all those single readings will have the same timestamp when written to the database. So, unless I am getting something wrong on this detail, everything would be still perfectly aligned on this matter. Please clarify otherwise. With kind regards, |
Hi Valentin, #41 integrates a decoder like you are looking at. It is no hassle for Kotori to carry and serve this and will save you from having to perform any republishing operations. I don't know how you are currently operating Kotori. Since porting it to Python 3 just recently, we have not been able to publish any recent distribution packages for Debian or images for Docker. If you are lucky, just whip it up within a development sandbox as outlined on [1] by switching to the
Remember to publish your data payloads to the With kind regards, [1] https://getkotori.org/docs/setup/sandbox.html Edit: There's also another way to install Kotori on behalf of this branch without having to clone from Git. Using a recent version of
|
Hi, first of all, thank you very much for implementing the 'bulk-json-compact' format, it's perfect for my case. However I'm having trouble getting it to work (probably I have some kind of error in the sandbox setup, but I think I followed the instructions correctly...) First I cloned the branch Finally I launch Kotori with
On the side I launch my measures generator to publish in the topic
However in Kotori's log I don't see anything, and neither in Grafana (which is working because when I make any query I see it in the corresponding log). I've checked and the access data to Grafana are correct in As I say, I'm probably missing something in the Python environment part, but I've already gone around a few times and I can't find the problem. Any ideas? Regards. |
Hi Valentin, thanks for your efforts trying out the new feature. I hope that we will get this going on your end and will take the chance to explain some details how Kotori and its configuration works. While some aspects might already be obvious to you, there might still be things to learn. I hope you appreciate it. General informationWithin the
Those schemes implement the channel address and will get applied to both the MQTT topic and the HTTP URI. While the first addressing component Your scenarioSo, you might be able to see Kotori pick up those measurement submissions successfully by publishing to MQTT topics like:
With the current configuration you are running, Kotori probably completely ignores all submissions to the Working exampleAssuming you are using a POSIX shell, a full publishing example based on your scenario would be # Define channel and data.
CHANNEL=basic/node-42
DATA='{"1611337127":{"Vehicle_Speed":0,"BMS_VDC":376.47058823040004,"BMS_Power":1.6383978618250694e-8,"BMSCurrent":0.0003583999999818843,"BMS_SOC":94.921875},"1611337128":{"Vehicle_Speed":0,"BMS_VDC":376.47058823040004,"BMS_Power":1.6383978618250694e-8,"BMSCurrent":0.0003583999999818843,"BMS_SOC":94.921875}}'
# Submit measurement.
echo "$DATA" | mosquitto_pub -h localhost -t "$CHANNEL/tc.json" -l If that is successful, the kotori.log: tc.json example
Can you give this a spin and then report back to me about the outcome? With kind regards, P.S.: If you are successful with this, while still running in development/sandbox mode (but without Lines 17 to 18 in 1a18bd1
kotori.log: transactions per second
|
Hi, perfect! the problem was indeed in the MQTT topic. Now I understand the nomenclature you use and how the path should be to work correctly. I've made a quick test with one of the topics you put in your last answer and now I can see the measures in Grafana, using the "bulk-json-compact" format: This will allow us to make great progress in our project, since until now we needed to export the data to a specific tool in order to analyze it. With your solution we can now see the values in real time without any effort. Again, I can't thank you enough for your work with the project and with this issue in particular. Best regards. |
Hi Valentin,
That is really important for effortless data visualization in scenarios like yours. We are glad that we have been able to help. Let's keep this issue open until the wip branches have been integrated into mainline. While I believe the functionality is fine already, it still lacks documentation. Until this is added, we might still use this issue for discussing some details around it. I wish you much success with your project. With kind regards, |
Hello,
I've searched the documentation but I didn't find nothing about this. In my case, I've a telemetry source that sends local data stored for a period of time, so each message includes several individual measurements (each one with a timestamp).
As an example, one of my measurements would look like this:
{"1611082554":{"temperature":45.2}, "1611082568":{"temperature":45.3}}
Is it possible to handle such data format from Kotori or is the timestamp always set when each individual measurement is received on the server?
Greetings.
The text was updated successfully, but these errors were encountered: