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

$__interval template doesn't work #372

Closed
povilasv opened this issue Mar 5, 2020 · 13 comments
Closed

$__interval template doesn't work #372

povilasv opened this issue Mar 5, 2020 · 13 comments

Comments

@povilasv
Copy link
Contributor

povilasv commented Mar 5, 2020

Currently my change #357 broke dashboards

I tried multiple different ways in grafana UI to fix it, by changing variable template to 'constant', 'text box' type with value $__interval, but it just doesn't render :/

I think there are 2 options:

  1. We can get rid of grafana template and "hard code" $__interval into queries

I mean getting rid of this part:

    local intervalTemplate =
      template.new(
        name='interval',
        datasource='$datasource',
        query='$__interval',
        current='5m',
        hide=2,
        refresh=2,
        includeAll=false,
        sort=1
      ) + {
        auto: false,
        auto_count: 30,
        auto_min: '10s',
        skipUrlSync: false,
        type: 'interval',
        options: [
          {
            selected: true,
            text: '$__interval',
            value: '$__interval',
          },
        ],
      },
  1. Don't use $__interval

What should we do?

@brancz
Copy link
Member

brancz commented Mar 5, 2020

Maybe grafana folks could chime in @beorn7 @gouthamve or maybe @roidelapluie has some insight.

@beorn7
Copy link
Contributor

beorn7 commented Mar 5, 2020

I'm actually not really a Grafana expert. We could loop in the real experts if needed.

But let's use our own ingenuity first.

My guess is that $__interval doesn't work with template variables. (Perhaps you would need some kind of two layers of variable expansion? But I honestly don't quite understand what you are trying to accomplish here.)

Different question: What's wrong with using $__interval in the queries directly? What are the circumstances where you want to use something else?

@brancz
Copy link
Member

brancz commented Mar 5, 2020

I think it was just that we had specific values previously and wanted to avoid creating work for us should we want to switch back again. If there’s nothing then I’m happy with using the variable directly though.

@beorn7
Copy link
Contributor

beorn7 commented Mar 6, 2020

I see.

I'd indeed recommend to go for $__interval always (with a reasonably setting for min step to avoid that the $__interval becomes too short, something like four times the scrape interval).

This should be "almost" right in probably all the cases. For the related problem of getting "true" coverage, see grafana/grafana#21417

@kyrogue
Copy link

kyrogue commented Apr 15, 2020

This is breaking the master branch.

generated dashboards .json are having the $__interval placeholder, it should be a numeric instead.

Previous changes added the $__interval template , and then removed it , however the $__interval placeholder present in dashboards did not get updated with the appropriate values.

@brancz
Copy link
Member

brancz commented Apr 15, 2020

@povilasv can you double check this?

@beorn7
Copy link
Contributor

beorn7 commented Apr 15, 2020

$__interval is a Grafana-specific thing. Only inside Grafana, it will be populated with a numeric value. Jsonnet has to render it as $__interval.

@povilasv
Copy link
Contributor Author

povilasv commented Apr 15, 2020

My PR (#383) just removed unused variable, don't see how it could break master.

I also tried to generate dashboards from master branch and everything is fine.

This is what get's generated:

               "targets": [
                  {
                     "expr": "(sum(irate(container_network_receive_bytes_total{cluster=\"$cluster\", namespace=~\"$namespace\"}[$__interval])\n* on (namespace,pod)\ngroup_left(workload,workload_type) mixin_pod_workload{cluster=\"$cluster\", namespace=~\"$namespace\", workload_type=\"$type\"}) by (workload))\n",
                     "format": "table",
                     "instant": true,
                     "intervalFactor": 2,
                     "legendFormat": "",
                     "refId": "A",
                     "step": 10
                  },

and it render fine in Grafana.

@kyrogue
Copy link

kyrogue commented Apr 15, 2020

Screen Shot 2020-04-15 at 8 41 08 PM

is there additional configuration required in Grafana(6.7.1) for the internal variable $__interval to be rendered? If i were to change $__interval to 5m it will work.

@povilasv
Copy link
Contributor Author

What's the time range you are looking at and Prometheus scrape interval?

Try increasing the window to last 2 days? Does it render?

@kyrogue
Copy link

kyrogue commented Apr 15, 2020

Ah, increasing Grafana time range to 24 hours worked, anything below does not render.
Thanks.
I suppose this is because the range is too short and Prometheus does not have enough datapoints to render onto the graph panel?

@beorn7
Copy link
Contributor

beorn7 commented Apr 15, 2020

Yeah, you need to set a Min step or Min time interval.

Shameless plug: I had planned to do a talk about exactly that at Grafanacon. With the conference being Corona-cancelled, there will be some kind of online version of that. See https://grafana.com/about/events/grafanacon/2020/ for more details in the close future.

@povilasv
Copy link
Contributor Author

👍

I'm closing this issue as it has been solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants