Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide other formats for time ranges #10

Closed
retzkek opened this issue Apr 25, 2020 · 6 comments
Closed

Provide other formats for time ranges #10

retzkek opened this issue Apr 25, 2020 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@retzkek
Copy link
Contributor

retzkek commented Apr 25, 2020

Different APIs will expect different time formats, so we need to provide a way to specify the format for $timeFrom and $timeTo. At a minimum there should be a way to get ISO8601 formatted strings. I'm not sure if we need or want to go as far as supporting arbitrary format strings.

Maybe just add $time{From|To}ISO for now?

@retzkek retzkek added this to the v1.2.0 milestone Apr 25, 2020
@retzkek retzkek added the good first issue Good for newcomers label Apr 25, 2020
@retzkek
Copy link
Contributor Author

retzkek commented Apr 25, 2020

If we were going to support more or arbitrary formats, maybe we should follow the convention Grafana uses for template variables, e.g. ${var:raw}. So for instance $timeFrom is epoch-millis, while ${timeFrom:ISO8601} would be ISO, etc. Much harder to implement of course, although maybe there's something in the Grafana libraries we can leverage.

@retrodaredevil
Copy link
Contributor

retrodaredevil commented Apr 25, 2020

I definitely like the idea of using the standard way of substituting that Grafana has with stuff like templateSrv.replace. I think there's a way to make it so you can do stuff like [[variable_name]] instead of $variable_name if you wanted to.

Maybe instead of using a regex to replace the necessary fields, we could use a more standard way. More info here: https://grafana.com/docs/grafana/latest/reference/templating/

I don't think this is too difficult and I don't think it would break any existing queries if we stopped using regex. I assume there's a library function to use like you said.

@retzkek retzkek added the enhancement New feature or request label May 11, 2020
@retzkek
Copy link
Contributor Author

retzkek commented May 12, 2020

Rather embarrassingly I've just been informed by @marcusolsson that there's global variables for the dashboard time range in epoch-millis since 6.0, so we should definitely promote using those, and work with core Grafana to support other formats instead of trying to invent our own.

@retrodaredevil
Copy link
Contributor

retrodaredevil commented May 12, 2020

So could this issue be renamed to something like "Use standard template variables for everything", since we eventually should stop using regex to replace stuff and use Grafana's way.

Or this issue could be closed and we create a new issue.

And of course maybe another issue to rewrite examples and default queries.

@retzkek
Copy link
Contributor Author

retzkek commented May 12, 2020

I've updated the README. I'm going to leave this issue open since it's pretty important for this datasource, probably moreso than for others. I found an issue requesting time range variables in seconds, I'll chime in there to request ISO8601 (and others) as well.

since we eventually should stop using regex to replace stuff and use Grafana's way.

I've opened #18 for that.

@retzkek
Copy link
Contributor Author

retzkek commented Aug 13, 2020

Good news everyone, this was added in 7.1.2: grafana/grafana#26466
https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/#__from-and-__to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants