I got trouble showing IP address in a plain table. There is no error, but the table show up empty. Any idea what wrong with my query?
Its a json extract query and the table contains a lot more info, but its only the IP i can’t extract.
Result in prompt is ok (below), but not in Grafana, where i just get an empty table.
mysql> select attributes->’$.ip’ from deviceinfo;
| “178.232.147.109” |
| “178.232.147.109” |
| “178.232.147.109” |
±-------------------+
6694 rows in set (0,13 sec)
I can successfully extract anything but the IP adress from content below using previous command.
Please check the query inspector in Grafana for your query and check what kind of data that is returned in the response, if ip is included please paste the response here. Could also be that you need to add a column style for ip address so that is rendered as string.
Its a null only in the reply, leading me to suspect that it doesn’t handle the " "
;
;
from Granfana:
sql:"SELECT UNIX_TIMESTAMP(devicetime) as time_sec, coalesce(attributes->’$.ip’, ‘’ ) as value, deviceId as metric FROM deviceinfo WHERE deviceId = 1 ORDER BY (devicetime) ASC"
series:Array[1]
0:Object
name:"1"
points:Array[4254]
0:Array[null,1516913348000]
1:Array[null,1516932415000]
2:Array[null,1516948637000]
3:Array[null,1516949029000]
;
;
Wheras querying for something else is OK
;
;
sql:"SELECT UNIX_TIMESTAMP(devicetime) as time_sec, coalesce(attributes->’$.io5’, ‘’ ) as value, deviceId as metric FROM deviceinfo WHERE deviceId = 1 ORDER BY (devicetime) ASC"
series:Array[1]
0:Object
name:"1"
points:Array[4254]
0:Array[null,1516913348000]
1:Array[null,1516932415000]
2:Array[null,1516948637000]
3:Array[50,1516949029000]
4:Array[65,1516950647000]
5:Array[60,1516950948000]
Since you’re using the table panel you shouldn’t need to use the column name returned as value. I think there may be some special handling of value column for time-series queries. So try and return a column named ip for example.
Also make sure that Format as table is selected:
Also make sure that you have selected table transform table under the options tab.
Think you need to name the timestamp column returned from query Time. Then the default column style will apply and format the column as date. If you add a custom column styles you can return basically any name of your columns. You also need to skip the UNIX_TIMESTAMP, i.e.