Support time macros in jsonata expressions within Parsing options & Result fields #1099
jeremygiberson
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all thanks for this project and all your work on it! It's been a godsend for me and satisfied many use cases already.
Describe the Feature
I would like to see the
$__timeTo
and$__timeFrom
macros respected in theParsing options & Result fields
for the backend parser. These macros are already supported in request body and query parameters which is excellent -- but I'm finding myself desperately wanting to be able to reference the relative time values I'm using in my api calls within the data being returned to grafana.Additional context
Admittedly my use cases thus far for these variables w/in jsonata expressions is pretty hacky.
For (the most simple) example (that I have a workaround for), I have an endpoint that returns a summed value for the last 3 days and last 3 months. Given that I'm viewing the dashboard at any given time during a day, or any given day during a month the 3rd value for the month and day sums represent month-to-date or today-so-far. Displaying these data points in a stat panel for example and calculating % difference from first and last value will always show an underrepresented value for the current day/month and falsely look super good (major % decrease).
In this case I can grab the unix timestamp of the
$__to
variable and modulo 86400 to get elapsed seconds today and then know what % of today's total value is being represented (roughly speaking as the value doesn't increase at a constant rate over the course of the day) and can do some math project what todays total will be. Similarly I can do${__to:date:YYYY-MM}-01T00:00:00.000Z
and then use $toMillis() to convert to unix timestamp. Unfortunately the workaround falls apart if the dashboard user changes the time picker to an absolute date range instead of a relative time range.If the
$__timeTo
and$__timeFrom
macros were respected I could set the query options w/ fixed time shift and keep my panels working regardless of the user selected dashboard range.Screenshots
A contrived example showing
$__from
and$__to
being parsed, while$__timeTo
, and$__timeFrom
are left intact.Beta Was this translation helpful? Give feedback.
All reactions