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

Feature Request: variables in X/Y-Max/Min #3935

Closed
hryamzik opened this issue Feb 4, 2016 · 51 comments · Fixed by #36548
Closed

Feature Request: variables in X/Y-Max/Min #3935

hryamzik opened this issue Feb 4, 2016 · 51 comments · Fixed by #36548

Comments

@hryamzik
Copy link

hryamzik commented Feb 4, 2016

Let's say you have a set of network graphs for several servers. They all have different scale as Y-Max is set to auto. You can set it to 1073741824 ( 1 gigabit ) for all the graphs but it won't make much sense. Defining a max value with a template variable could be really helpful in this case.

@xelite
Copy link

xelite commented Feb 11, 2016

+1
Also option to set equal values on left and right Y-Max on a same graph.

@etlweather
Copy link

Similar use case for me. I have ping response time. I have a dashboard which shows today, yesterday, last week, comparison graphs. For a certain host, I may want 0-100ms as the scale, another host, on LAN, I may want to see 0-15ms scale so I can see changes on the graph. Right now I defaulted the dashboard to a certain value and have to change 3 graphs if I want to use a different scale.

@torkelo
Copy link
Member

torkelo commented Sep 15, 2016

implemented in #6051

@torkelo torkelo closed this as completed Sep 15, 2016
@stockto2
Copy link

You're sure this was included in 6051? I still can't use template variables in Y Max, after building from most recent source code.

@torkelo
Copy link
Member

torkelo commented Nov 1, 2016

They issue was reversed due to issues

@tricky42
Copy link

Any timeline on when it will be included again?

@Ulrar
Copy link

Ulrar commented Dec 28, 2016

Hi,

Is there a way to do that ? For a memory graph for example, knowing 4 Gb are used is good but not having the max makes the graph a bit useless .. It'd be great if I was able to use a query as Y-Max (since the total is collected).

@LeDistordu
Copy link

Hi,

It would be great if you could use item as Y-max, like item memory total

@relishcolouredhat
Copy link

Also came here looking for this feature. Very surprised everybody does not need this.

@omarmarquez
Copy link

+1

@rodolfosalgado
Copy link

+1
This is quite important to any chart as memory / disk usage / CPU...

@Veance
Copy link

Veance commented May 11, 2018

+1

1 similar comment
@jonathanspw
Copy link

+1

@douglasg14b
Copy link

This would very much be wanted, some graphs looks a bit ridiculous without it.

@Izdatyi
Copy link

Izdatyi commented May 31, 2018

+1

@tecmatia-dp
Copy link

tecmatia-dp commented Jul 9, 2018

This change is working for me, in file "graph.ts", from...

      function parseNumber(value: any) {
        if (value === null || typeof value === 'undefined') {
          return null;
        }

        return _.toNumber(value);
      }

to...

      function parseNumber(value: any) {
        if (value === null || typeof value === 'undefined') {
          return null;
        }

        return _.toNumber(ctrl.templateSrv.replace(value, ctrl.panel.scopedVars));
      }

With this, it accepts dashboard variables in Y-min/max.

@adriananeci
Copy link

+1

@hryamzik
Copy link
Author

@tecmatia-dp can you make a PR for this, please?

simPod added a commit to simPod/grafana that referenced this issue Dec 3, 2018
@simPod
Copy link
Contributor

simPod commented Dec 27, 2018

@hryamzik see the PR, was closed tho :/

@ohrly
Copy link

ohrly commented Apr 4, 2019

I like to have this with a variable or a direct query option:
I have thresholds within the datasource and I like to scale the graph from Y-Min: 0 to Y-Max: $threshold+0,1 basically!
But flexible Y-Min/Y-Max values would be also good, like often requested: >720 <292 and so on!
Would be greatly appreciated!

Edit: In this post I have some details: #8281 (comment)

@hdlbq
Copy link

hdlbq commented Sep 25, 2019

+1

1 similar comment
@scheka
Copy link

scheka commented Oct 19, 2019

+1

@douglasg14b
Copy link

Please just use the reaction and not spam +1 comments.....

@simPod
Copy link
Contributor

simPod commented Feb 20, 2020

My #6477 was not complete. It is needed to resolve variables in axis also before running updateLegendValues().

@slimsag
Copy link

slimsag commented Apr 14, 2020

Would a PR that adds support for this be accepted? Or is there a reason this is tricky behavior to add and it needs further discussion about how it would be implemented?

@philbour
Copy link

I created a variable to use in the max field for the gauge visualization but was surprised to find I couldn't! This is really needed. I run load tests with different loads, I have to keep changing the max value for the dashboard to look presentable.

Surprised that after 4 years and all the requests, this has still not been worked on.

@rmarabini
Copy link

+1

@thijsdebont
Copy link

I was surprised to find this is not implemented in Grafana. Seems such an intuitive feature. So +1 for the feature request.

@hb0nes
Copy link

hb0nes commented Jun 4, 2020

This change is working for me, in file "graph.ts", from...

      function parseNumber(value: any) {
        if (value === null || typeof value === 'undefined') {
          return null;
        }

        return _.toNumber(value);
      }

to...

      function parseNumber(value: any) {
        if (value === null || typeof value === 'undefined') {
          return null;
        }

        return _.toNumber(ctrl.templateSrv.replace(value, ctrl.panel.scopedVars));
      }

With this, it accepts dashboard variables in Y-min/max.

How would I use a variable after changing this .ts file? I have applied the changes but don't know what to input in the 'max' field in my bar graph.

@tecmatia-dp
Copy link

How would I use a variable after changing this .ts file? I have applied the changes but don't know what to input in the 'max' field in my bar graph.

Use $var_name like in other valid places.
This fix is tested with Grafana v5, I don't know if still works in v7.

@gaurishprabhakar
Copy link

+1

@wiku-PSNC
Copy link

This fix is tested with Grafana v5, I don't know if still works in v7.

Hi @tecmatia-dp , could you please verify if it still works in v7? This fix could help me very much, but so far it doesn't work for me. :(

@wiku-PSNC
Copy link

wiku-PSNC commented Jun 26, 2020

Hi @tecmatia-dp , could you please verify if it still works in v7? This fix could help me very much, but so far it doesn't work for me. :(

I've discovered, that after changing graph.ts file the app.7b506073f46893460c0d.js (from grafana_7.0.4_amd64.deb) webpack has to be rebuild but at this moment I've no idea how to do it.

@h3krn
Copy link

h3krn commented Sep 24, 2020

@wiku-PSNC , I don't know if this is still helpfull, but will post anyway.

I've followed the "developer instructions" to clone and build the grafana frontend from source.Then I've updated public/app/plugins/panel/graph/graph.ts in the source tree with a slightly modified fix and rebuild:

  parseNumber(value: any) {
    if (value === null || typeof value === 'undefined') {
      return null;
    }

    return _.toNumber(this.ctrl.templateSrv.replace(value, this.ctrl.panel.scopedVars));
  }

Finally I've replaced /usr/share/grafana/public from the binary package, with the one I build from source and restarted the grafana-server.

I don't know if there's a easier way. But for me, this works like a charm.

@tgtwm1github
Copy link

@noharm Is it possible to share your build? It will greatly help.

@h3krn
Copy link

h3krn commented Dec 23, 2020

I've made a fresh build. You can find a tgz of the "public" directory here

@tgtwm1github
Copy link

The link draws a blank page.

Is there any way you can share it via github?

@namadori
Copy link

namadori commented Mar 3, 2021

I am really surprised, this seems a very basic feature (my first use for a variable is to set the Y-Max value across many charts) that almost everyone will need, and 5 years after the first post it is still not implemented.
Is there any way to draw the attention of the developers to this issue? From @tecmatia-dp it also seems to be pretty easy to implement.

@HaydenBurrows
Copy link

HaydenBurrows commented Apr 22, 2021

@noharm

A small modification with your code gets y min/max variables working for me. Removing _. from this line:
return _.toNumber(this.ctrl.templateSrv.replace(value, this.ctrl.panel.scopedVars));

For my purpose it allows a text variable/s which a user can populate with a number of their choice.

This was tested using Grafana 7.5.0 1619131092pre
I will test with 7.5.4 also to see if it all good.

@torkelo
Copy link
Member

torkelo commented Jul 15, 2021

So in v8.1 we are adding two new transforms that will allow you to extract config like min, max, unit and thresholds from a normal query:

Config from query results
Rows to fields

We are soon switching to Github discussions for feature requests, will create an issue there next week to collect feedback on these new transforms

@19wolf
Copy link

19wolf commented Mar 1, 2022

^Those two links are dead. What's the current status of this and how do I make it work?

@axsuul
Copy link

axsuul commented Aug 4, 2022

The updated links are:

Config from query results
Rows to fields

@ErikEngerd
Copy link

I am not sure that the above will cover my use case. As part of troubleshooting I am using grafana to display two panels for the same metric. One with the current time interval and one with a time shift (configured in a text box variable). The most common case is to use a time shift of 1 week because results between different days of the weeks can usually not be compared. In this troubleshooting scenario, it is essential that the time scales are the same. Preferably, I would also like to show the metric and time-shifted metric in the same graph to allow an even easier comparison.

Now, I basically would like the option to configure the axis ranges for the two panels using a for instance a variable, or to tie the y ranges for the two panels together. It is essential that the two time ranges are the same.

If I use the config from query result option than I can determine the min and max for the given time interval, but the other panel with the time shift will then still return different values for min and max.

In general, it would also be a good solution to show the metric together with the time shifted metric in the same graph.

@yayitazale
Copy link

So in v8.1 we are adding two new transforms that will allow you to extract config like min, max, unit and thresholds from a normal query:

Config from query results Rows to fields

We are soon switching to Github discussions for feature requests, will create an issue there next week to collect feedback on these new transforms

The scope of that is different. I don't want to only be able to config the scale from a query, I want to be able to use a custom variable and change the chart with the selected option, so a regular user is able to dive into concrete max/min area of the Y axis.

@simPod
Copy link
Contributor

simPod commented Jan 24, 2024

@torkelo any idea how to use the config from query?

I configured it but it converts all my series' names to Value. I just want to set one series' Max. I'd at least expect it not to affect all my series when I constrain Apply to options to a single series.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment