Duet3 reading the metrics...
-
Hi *,
I have a Duet 3 and a raspberry connected to it. So my idea is now to read out some metrics from the Duet and write them to a time series database for further analytics.
My idea is to use telegraf (https://www.influxdata.com/time-series-platform/telegraf/) and write the data to a influxdb (https://www.influxdata.com/). The tools for graphs will be grafana. (https://grafana.com/)I user grafana, influx and telegraf in my job and at my home environment, so that should be a peace of a cake.
My question is now: How can I read out the data from the Duet? The telegraf can execute commands/scripts to gather information. But where can I get information from? I think about hotend temperature, current layer No, time of the print? etc etc....
Can I get that information form the serial interface? Or does one of the daemons provide that?
(Yes I can provide a guide when I have something "ready".)
Cheers, Chriss
-
@Chriss The new firmware RRF3 which is used by Duet 3 introduced a object model, which provides those information in json format, which you can get.
As a first overview, you can check the links
https://duet3d.dozuki.com/Wiki/Object_Model_of_RepRapFirmware
https://duet3d.github.io/DuetSoftwareFramework/api/DuetAPI.Machine.MachineModel.htmlThe first links gives in chapter "Uses" an overview how you can transfer the data.
-
Nice..... Thanks. I will source that json document from the web interface than. There is json plugin for telegraf which makes it very easy to handle that.....
I have a duet2 main-board around, too. So I will source the the data from the web-interface, too.
Well, I want to keep my 3D printer(s) as much self contained as I could. So it would be very convenient to use the local connected raspberry to query the local web service for the data. The data can than be stored in a local influxdb. The PI4 has more than enough resources for that.
Cheers, Chriss
-
@Chriss Hey, could you give an update on the topic? I'm attempting the same thing with the Duet2 Wifi at the moment and would be glad to get some input!
Regards
Niklas -
Hey Niklas,
Well, the setup is almost done.
The most important part is still missing. I have some problems with the json input plugin for telegraf. I postponed that for my other printer which have some mechanical issues. I can provide some more info and what I did so far if needed. I would be more than happy if somebody can take over the task and finish the very last step in the setup. Are you volunteering ?
Cheers, Chriss
-
@Chriss
Hey Chriss,
so you can already read the metrics in form of a Json file? Do you use M409 or rr_model command? Would be great if you shared some of your steps as I've just started to work with the duet board.
I think that I will also use telegraf anyway. So I can share my progress with the json plugin with you once I've set up the basics
Regards
Niklas -
Hi Niklas,
sorry fir the late answer. My jobs consumes a lot of time at the moment.
Let me elaborate what I did so far:
1: Installed influxdb on the PI https://docs.influxdata.com/influxdb/v2.0/get-started/?t=Linux
2: Installed Grafana to make some fancy graphs: https://grafana.com/docs/grafana/latest/installation/debian/
3: Installed telegraf: https://docs.influxdata.com/telegraf/v1.18/introduction/installation/
All of that was not a surprise so far.I played with the json input plugin than:
https://docs.influxdata.com/telegraf/v1.18/data_formats/input/json/
https://stackoverflow.com/questions/62570876/parsing-json-file-using-telegraf-input-plugin-unexpected-outputThe status of the duet can be queried here:
http://localhost/machine/status
So this gives you the full status of the duet and all connected toolboards etc.I tried to read the "board0_vIn" from the json code for testing. That example below does not work and reflects the state where I left it:
[[inputs.http]] ## One or more URLs from which to read formatted metrics urls = [ "http://localhost/machine/status" ] # next field replace default metrics name "http" to your custom name: name_override = "board0_vIn" # set true if you want to ignore self signed certificate validation: insecure_skip_verify = true data_format = "json" timeout = "5s" # Here you can filter your JSON using special syntax: # json_query = "boards" # json_string_fields = ["boards_0_vIn_current"]
I hope that helps. I can spend some time into it as soon as we have at least one working example.
Cheers, Chriss
-
Hi Chriss,
thanks for the answer! I think I can use some of your input. I will update you as soon as I have made progress with the json plugin. It might take a while though, as I'm pretty busy atm...
Regards
Niklas