Grafana: Feature Request: variables in X/Y-Max/Min

Created on 4 Feb 2016  ·  43Comments  ·  Source: grafana/grafana

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.

arepanegraph typfeature-request

Most helpful comment

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).

All 43 comments

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

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.

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.

They issue was reversed due to issues

Any timeline on when it will be included again?

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).

Hi,

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

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

+1

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

+1

+1

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

+1

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.

+1

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

@hryamzik see the PR, was closed tho :/

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: https://github.com/grafana/grafana/issues/8281#issuecomment-480342496

+1
I also need this feature.

3 years later ...

I'd love to see this too. The (very minor) PR to add this feature was closed in favor of a complete rewrite that is "1 to 2 years" out!

Oh boy, we still need that. Please make it happen..

Would also like to have this feature

Would love to see this!

+1

+1

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

My https://github.com/grafana/grafana/issues/6477 was not complete. It is needed to resolve variables in axis also before running updateLegendValues().

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?

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.

+1

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

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.

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.

+1

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. :(

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.

@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.

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

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

The link draws a blank page.

Is there any way you can share it via github?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KlavsKlavsen picture KlavsKlavsen  ·  3Comments

jackmeagher picture jackmeagher  ·  3Comments

calind picture calind  ·  3Comments

yuvaraj951 picture yuvaraj951  ·  3Comments

ahmetkakici picture ahmetkakici  ·  3Comments