How can I merge rows in a grafana table panel?


#1

Good morning, I’m trying to make a table with timeseries data that is stored in influxdb. I’m using the grafana table panel. When my two returned values has the same timestamp my table is showed properly but when the two returned values has a diferent timestamp they are showed in diferent rows (they are in the same second but not in the same milisecond). I want to know how can I change my query to has values in the same row although they are not in the same timestamp (precision of seconds not miliseconds). I think that the solution is to change the epoch param or the precision param but I dont know how to do it. Can anyone help me?

Here is my table:

Here is my query:

Thank you in advance


#2

I’m not sure if it possible to change the precision of the timestamp in the query.

One option is to aggregate (group by) time, for example group by minute or group by 1 second.

GROUP BY time(1s)

Another solution is to use a coarser timestamp when writing the data to Influxdb: https://docs.influxdata.com/influxdb/v1.7/troubleshooting/frequently-asked-questions/#does-the-precision-of-the-timestamp-matter


#3

I understand what you are saying but if i write group by time (1s) I dont see anything. All my timestamps are within 1s


#4

How can I set the precision to seconds when defining a panel?


#5

Just to double check - do you mean that everything got grouped to one row or do you mean that you got no data returned? If no data was returned then it sounds like you did not write a valid query with an aggregation function.

Sorry - don’t know if there is a way to do that and I couldn’t find anything in the docs for InfluxDB.

It looks like you can set the precision for queries and writes for the database with a flag when you start the InfluxDB service:

https://docs.influxdata.com/influxdb/v1.7/tools/shell/#precision-rfc3339-h-m-s-ms-u-ns

Maybe someone on the InfluxData forum knows how to specify it in a query.


#6

I dont know why but theres no data returned when I group by time. Do you know why?


#7

results:Array[1]

0:Object

statement_id:0

error:“not executed”


#8

What does your query look like after you added the group by time?


#9

It looks like this:
"SELECT “value” AS “IdUv” FROM “mqtt_consumer” WHERE (“topic” = ‘Instalacion/0/UVComs/UV/1/IdUv’ OR “topic” = ‘Instalacion/0/UVComs/UV/2/IdUv’) AND time >= now() - 6h GROUP BY time(1s) ORDER BY time DESC LIMIT 2;