Hello,
Please excuse my newbie questions… I’m quite new to Grafana.
I’m currently using it with PostgreSQL + TimescaleDB as datasource to plot data from an electric gokart with custom Arduino Mega / XBee Pro telemetry (and a Go script to fill database).
Database is composed of 3 tables (see SQL create statements)
CREATE TABLE syst_evt (
time TIMESTAMPTZ NOT NULL,
id INTEGER NULL,
millis INTEGER NULL,
msg VARCHAR
);
CREATE TABLE line_evt (
time TIMESTAMPTZ NOT NULL,
id INTEGER NULL,
millis INTEGER NULL,
line SMALLINT NULL
);
CREATE TABLE data_evt (
time TIMESTAMPTZ NOT NULL,
id INTEGER NULL,
millis INTEGER NULL,
rpm DOUBLE PRECISION NULL,
speed DOUBLE PRECISION NULL,
torque DOUBLE PRECISION NULL,
vbat DOUBLE PRECISION NULL,
ibat DOUBLE PRECISION NULL,
tvar DOUBLE PRECISION NULL,
tmot DOUBLE PRECISION NULL,
ax DOUBLE PRECISION NULL,
ay DOUBLE PRECISION NULL,
az DOUBLE PRECISION NULL
);
The first table sys_evt contains system events (when telemetry is switched on for example)
The second table line_evt contains line events ie when gokart is crossing lap line (we measure this using a reed switch and a magnetic band embedded in the track)
The third table data_evt contains data event (essentially data from speed variator : motor speed, temperature of motor, of variator, voltage, current…)
id is an identifier for each gokart (currently we only have one gokart in this system but it could evolve)
On a dashboard I have been able to simply add a graph panel to draw rpm as a function of time.
SQL query looks like:
SELECT
"time" AS "time",
rpm
FROM data_evt
WHERE
$__timeFilter("time")
ORDER BY 1
That was quite easy but I would like now to parametrize this graph by id (ie I want to be able to first choose a given id and then graph should only plots rpm for gokart of this given id.
I can manually change query to
SELECT
"time" AS "time",
rpm
FROM data_evt
WHERE
$__timeFilter("time") AND
id = 12345
ORDER BY 1
But if I plot several graphs (rpm, ubat, …) I won’t change id on several graph… I’m looking for a way to do it more “globally”.
Do you have any tips to achieve this?
An other point
I want to add on this graph, markers (vertical lines) when gokart is crossing line but I don’t know how to add such markers on graph. Any idea?
Kind regard

