admin管理员组

文章数量:1357456

I'm publishing sensor data using Zenoh, and my backend storage is InfluxDB via the Zenoh Router.

Currently, I publish a float value like this in C++:

void ControllerPublisher::publishSpeed(float speed)
{
    throttle_pub->put(std::to_string(speed));  // Publishing as a string
}

However, when the data is stored in InfluxDB, the _value column appears as zenoh/bytes, I can visualize it as a table but once I try to visualize it in InfluxDB graphs or Grafana I can't. In the beginning I thought it was simple strings and I tried using different approaches like (toInt(), select cast() in sql) but all of them failed. This led me to realize that the Zenoh Router is storing the values as raw bytes instead of numbers or strings.As you can see in the image the _value is 0 in the graphs part.

  • How can I properly convert zenoh/bytes stored in InfluxDB back into a float/int?
  • Is there a way to force Zenoh Router to store numeric values correctly in InfluxDB? Should I modify my Zenoh publisher to ensure it sends data in a format that avoids zenoh/bytes issues?

As you can see in the images, the value is written as "string" type and it appears in a table but not in a graph.

influxDB table - column _value appears
InfluxDB graphs - _value is always 0

At first, I thought the _value column stored simple strings, so I tried common conversions in Flux, SQL, and other environments, but none worked.

  • In Flux (InfluxDB Query Language):

    |> map(fn: (r) => ({ r with _value: int(v: r._value) })) 
    |> map(fn: (r) => ({ r with _value: float(v: string(v: r._value)) }))  
    
    • Expected: The _value column should be cast to an integer or float.
    • Result: Error due to zenoh/bytes format.
  • In SQL:

    SELECT CAST(_value AS SIGNED) FROM my_table;
    SELECT CONVERT(_value, SIGNED) FROM my_table;
    SELECT _value + 0 FROM my_table; 
    
    • Expected: MySQL should convert _value to an integer.
    • Result: If _value were a string, it would work—but since it’s zenoh/bytes, conversion fails.

本文标签: