Can we create our own time variable?

  • What Grafana version and what operating system are you using?
    Latest version of grafana and os is windows

  • What are you trying to achieve?
    I am trying to create my own time variable

  • How are you trying to achieve it?
    using variable, values in variable are ‘this week’, ‘this month’, ‘this year’, etc

  • What happened?
    I am not able to use those values in my SQL query

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

Hi @mayurvidhwani7387, can you clarify what you’re trying to achieve? Do you want to have a template variable that has a drop-down with text like “this month”, but then values that correspond to the actual bounds of the month, which you can use in a query?

Are you not able to simply use Grafana’s existing time selector? Maybe you can say a few words about why that doesn’t work for you.

Actually, the task which I have been assigned requires me to create our own time variable and not use the Grafana time filter.
Is it possible to create it in Grafana?

I don’t think there’s a great way to recreate the functionality of the time picker using template variables.

There may be a workaround that involves a key-value variable but it would be complex, ugly, and fragile, and I wouldn’t recommend it. Might be better to rethink the necessity of doing this.

1 Like

This topic was automatically closed after 365 days. New replies are no longer allowed.