Modifying time panels options

Is it possbile to show less number of time ranges in grafana. ?Right now the grafana main dashboard contains follow time ranges:

I want to show only limited time ranges, say 2 days and 1 week . Is it possible ?

Unfortunately not possible. See e.g. Adding new persistent relative time ranges and To modify custom time range options

EDIT: forgot to mention, but (per the first thread) it’s possible to do it by modifying the source code. Just not as part of a standard install

Does that mean, I need to build from source after doing changes?

Not necessarily…maybe this post in one of the threads I linked to helps: Adding new persistent relative time ranges - #5 by svetb

I was able to change the time at rangeOptions.ts.

Parallely, I was trying to remove “Last 5 minutes” based on the comments made by you:

Alternatively you could look at the Grafana JS files on your server (if you have access to them) and search for e.g. “Last 5 minutes” to see where the time ranges are defined and modify the definitions there (likely app.xxxxxx.js ). Have in mind this would of course get wiped if you upgrade Grafana.

I did remove “last 5 minutes” from `app.xxxxxx.js" files but I could still see “Last 5 minutes” being displayed on panel. May i know if i need to do anything else ?

Did you restart the Grafana server and also clear your browser cache?

Note that I haven’t tested this approach personally, but it should work.

1 Like

Also, I wanted to add “Quarter to date” which will compute time from last quarter till today’s date. It was trivial to add “Quarter to date” on time panel but can you suggest which file I need to check to add or modify to populate time ranges corresponding to quarterly ?

If I’m not mistaken, there is a JSON object that you edited to remove the “Last 5 minutes” entry. I think you just need to add “Quarter to date” with the respective time boundaries to that same JSON object.

Thats true, I have added it like this from:“now/Q”,to:“now”,display:“Quarter to date”. But now i need to define what is now/Q. How can i do that ?

I have see a file name rangeutils.test which has section like :

it('should handle now/w', () => {
      const info = rangeUtil.describeTextRange('now/w');
      expect(info.display).toBe('This week so far');

Do I have handle now/Q here ? But i guess this file is for testing ?

I don’t know the answer to that question…partly because “Q” is not a unit of time I’ve come across before, and I doubt it’s one that Grafana understands. So you will need to dig a bit deeper into the codebase to make it supported. The test that you found is probably relevant, but I’m pretty sure it’s not the only thing that needs augmenting (partly because it’s just a test). [btw I thought previously you said you had figured that part out, but I probably misunderstood your comment.]

Yeah…yesterday I went looking for files where I could add functionality for Q( Quarterly till date ) but without any sucess.

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