Hi Community,
First to set the context, I’m using Grafana OSS 11.0.0 in a docker container.
MY AIM
In a dashboard, I have a list of events stored in a Postgres table. Those events are simply a list of:
- “start” TIMESTAMP
- “stop” TIMESTAMP
- “title” TEXT
- “tags” TEXT
To each line of the table, I’d like to apply a “Data link” to make the dashboard zoom in on the event time window. So I define my “Data Link” as
http://localhost:3000/d/be14qv4sb5qf4d/new-dashboard?orgId=1&from=${Date.parse(__data.fields.start)}&to=${__data.fields.stop:date}
WHAT HAPPENS
When clicking on the event, the dashboard time window does not change, because the &to=
and &from=
appear as formatted datetimes YYYY-MM-DDThh:mm:ss.xxxZ instead of a timestamp.
WHAT I TRIED
I tried then to create a variable in the query by forcing the date to timestamp.
SELECT
start,
stop,
title,
tags,
CAST(start as TIMESTAMP) ts0,
CAST(stop as TIMESTAMP) ts1
FROM
site_events
No change. The “timestamped” dates were reconverted to standard dates.
QUESTIONS
a) Is there a way to enforce the dates to appear as timestamps in the data link?
b) Is there another way to do what I’m aiming to do?
Thanks for your feedbacks.