Sparkline from SQL array

Greetings

i have a SQL table with following schema

create table users (
    id uuid primary key,
    data real[] not null
);

This data are just some ordered floating point values (sensor data).

Im using Postgres as data source and this query:

select
  user.id,
  user.data
from users as user;

Now, i want to create a simple Users table in my dashboard with 2 columns:

  1. User ID
  2. User DATA as Sparkline graph (or any other graph if possible)

Is this even possible ?

I was trying to override data column type to Sparkline but grafana says “no data”.

Should I format this data to any other format (or maybe i need indices for X axis).

Yes, you need time series.

Ok i found a solution myself.

You don’t need to have time series data.

Data needs to be queried like this

select 
   array_to_json(user.data) as "Data"
from users as user;

Then, data should be transformed using “Convert Field Type” to “Other”.

3 Likes