Ladder99 / fanuc-driver

Configurable Fanuc Focas data collector and post processor.
Apache License 2.0
72 stars 25 forks source link

Axis data available only as a string on influx - subsequently cannot be used in Grafana #113

Open anagaraj2 opened 4 weeks ago

anagaraj2 commented 4 weeks ago

Hello,

I am trying to collect axis data and display it on a real time grafana dashboard.

  1. If I use the config.system.yml file as it is, through dozzle I can see that the FANUC driver is collecting axis data but I don't see any of the axis data like position, load, power, etc. listed on the influxdb UI. To solve this issue, I followed the suggestion by another user (Issue #110 ) and put all the parameters in quotes. When all the axis.data parameters are in quotes in the config.system.yml file, the data is available on influx as a string. However, this works only when all the parameters are in quotes, not a selected few.

  2. Under the case when all the axis.data parameters are being collected as a string, I am able to see the data as a table on grafana - say my machine has 2 axes, the first column is time, the second column is the x axis data and the third column is the z axis data. I don't know the right way to query flux to plot only the second column data. An additional problem that arises here is due to the headers being parsed as strings and each word in the data header is within double quotes, I get syntax errors when trying to copy the header and query flux. I have tried many different ways to query flux but it does not seem to work.

Thank you!

anagaraj2 commented 3 weeks ago

I found a long and not the most optimal workaround for this problem...

  1. Keep the parameters within quotes so that all the data is collected and sent to influx.

  2. Link the data source to grafana.

  3. Use a flux query that converts the strings to float from(bucket: “fanuc”) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r[“_measurement”] == “axis”) |> filter(fn: (r) => r[“_field”] == “load”) |> map(fn: (r) => ({ r with _value: float(v: r._value), _time: time(v: r._time) }))

  4. At this stage, the grafana dashboard will plot all the data being collected on the same plot (X axis, Y axis, Z axis, etc.) but these can be selected by series name under the override options. Then the required data can be plotted by hiding every other series also available as an override option (hide in area).

P.S. I was not able to figure out the flux code to select the series directly and hence had to use the override option. There was an issue with the data headers having double quotes for each of the words (for example - load {axis=""X"", machine=""cnc1"", path=""1""}.