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.
本文标签:
版权声明:本文标题:type conversion - How to properly convert zenohbytes stored in InfluxDB to usable numeric values? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743930842a2563810.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论