Grafana: Support for playlist with templating variables

Created on 8 Sep 2014  ·  132Comments  ·  Source: grafana/grafana

Let me give you a simple example:
We have a dashboard that has $HOST variable configured.
We have a graph that uses aws.$HOST.request.count
When looking at the dashboard we can select Host1, Host2 etc, displaying the appropriate metrics.
Now, it would be nice to turn this into a playlist so that every minute, grafana displays the metrics for each host.

Things get a bit more complicated when we have two or more filters. There are a bunch of combinations, some of which may not be of interest for the dashboard watcher.
For this reason, it would be nice to have a way to select a list of filter/variable combinations that are interesting for the user. The playlist would then cycle through these combinations and display the dashboard with the appropriate metrics.
It would also be nice to make it possible to select different combinations for the time range as well in a playlist (eg. last 6 hours, last 24hours and so on).

aredashboard prioritnice-to-have typfeature-request

Most helpful comment

:cake: for the 5 year anniversary of this issue.

Can we get an update?

All 132 comments

@costimuraru very good suggestions!

:+1: will make the playlist feature so much more useful

:+1: This feature is needed beucause you don't have that huge screen to put all you graphs there.

:+1: Indeed, this feature would be great for projects like ours where we have many dashboards that may be compacted in a single screen.

This indeed sound very useful, but also pretty complex and time consuming to expose variable and time settings in the start playlist view (and implementing the logic to handle those settings and setup variables etc on dashboard load/cycle). So it will definitely be a feature too prioritize in the future but not something that can be squeezed in for v1.8

Thanks @torkelo and keep up the good work!

:+1: Would be great to have this feature

While this is in the dev queue -- is there anyway to specify the template variable in the url? I could at least use a browser extension to rotate through a bunch of urls for now.

@rishid yes, using ?var-<variable_name>=value

+1, I'm also very interested in this feature request

+1

+1

+1 With templating, this is a must.

PR coming very soon...

@costimuraru I have implemented playlist for one variable, now working on multi variable combinations. Implementation should be quick. Selecting different time range may be an upgrade feature on top of this. For this iteration, I am just doing template variable combinations playlist.

That's awesome, @utkarshcmu !

Here is the the PR - #2841 and some screenshots:

Go to "Templating" and now you should be able to see the brand new "Playlist" tab:
screen shot 2015-09-29 at 3 14 13 am

Click on Playlist tab and you should see the following screen with all the variables listed.
screen shot 2015-09-29 at 3 14 16 am

I selected 2 of the variables out of 3 and clicked on "Start". (The reason I selected 2 is because I want to play all the combinations of these 2 variables keeping the 3rd one fixed. Please Note: The fixed variables will get their default saved values).
screen shot 2015-09-29 at 3 14 22 am

Now you can see that I kept the first variable constant and a playlist will start with all the possible combinations of 2nd and 3rd variables.
screen shot 2015-09-29 at 3 14 36 am

Please provide feedback and changes if required.

Awesome @utkarshcmu

Nice work! not sure about having the playlist feature as a tab in the templating settings. There is already a playlist view, Building a playlist for a templated dashboard should be part of that view.

Agreed with @torkelo, I will make this a part of the playlist view. That makes more sense. :)

Playlist based on template variables can be triggered from the playlist view now. Following steps should be followed to start the playlist:

Click on Playlist:
screen shot 2015-09-30 at 10 59 44 am

You will see the following Playlist view with an additional option of choosing the playlist type:
screen shot 2015-09-30 at 10 59 50 am
Everything works same for the playlists based on dashboards.

Now for playlist based on template variables, you need to select "variables" from the dropdown menu:
screen shot 2015-09-30 at 11 07 37 am

Then you will search for dashboard for which you need to run the playlist based on its template variables and select it:
screen shot 2015-09-30 at 11 00 13 am

Once you select the dashboard, automatically the list of template variables will be show:
screen shot 2015-09-30 at 11 00 16 am

Now the next step is to select the template variables with which you want to run the playlist, and click on Start:
screen shot 2015-09-30 at 11 00 44 am

And here you go with the playlist based on template variables:
screen shot 2015-09-30 at 11 00 51 am
screen shot 2015-09-30 at 11 00 58 am

Let me know what do you guys think about this change in the playlist view.

looks good

+1

+1, any news about this feature @utkarshcmu ?

@evandro-portugal I implemented the playlist feature for grafana but it was not merged earlier. I think now I have to redo some work because the code has changed a lot.

@utkarshcmu right, where can I get your last codes for this? I would like to have a look and try to do something for me, in my case it's a high priority and I just need to make the variables change the position in the end of every cycle, then I could do something until we get your branch merged

@evandro-portugal
Here is the old code:
Please go to my fork of Grafana - https://github.com/justforkit/grafana
And try building Grafana from "variable-playlist" branch

@utkarshcmu , thanks, I'll have a look into the code, do you plan to rework the code? Else, I could share my work if I fix it for the actual master branch of grafana, which I'm using right now. I'll have a couple of holidays now (carnival here) and plan to play with it

@evandro-portugal Sure, go ahead and rework if you want to. I am not planning to work on it at least for a week here. Enjoy Carnival. :)

@torkelo Can this feature be merged into core grafana? This seems to be a very useful enhancement for playing the same dashboard with different template variables.

Also, if @bergquist / @torkelo agree on merging this feature, I can rework on my previous PR's code to make it compatible with the latest Grafana code.

@digrich what do you mean merged? This is not a PR :)

I was trying to refer @utkarshcmu's old PR(#2841) but as he mentioned in his last comment, he has to rework and submit a new PR.

+1

Hi @torkelo . While waiting for this useful feature I would like to look for any workaround.

Could be possible build something like a playlist based on a scripted dashboard ?

This scripted dashboard should be able to load other templated dashboards and pass variables in some way , from url perhaps?

+1

Is there any news about this given that it has been half a year?

No news :(

Looks like I need to take some time out for this feature request!

+1

+1

+1

+1

Since you can pass variables via URL, my temporary solution is this simple iframe carousel/rotator html page, which I call it the Grafana Dashboards carousel.

You just need to specify the BASE_URL and dashboards_list array, which contains dashboards that you want to display.

This is a slightly unrelated question but is there a way to just have a "next"/"previous" host (or really templated variable) button on a dashboard?
When I want to manually scroll through a whole set of hosts using the dropdown becomes very cumbersome.

Any actions here? All our dashboards are templated - so w/o template features / possibilities to pass vars the playlist feature is largely unusable to us.

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1, @utkarshcmu Are you still working on this? I'll take a stab at it if not but I'm pretty new to grafana development

@thattolleyguy - Go ahead buddy, I am not working on this anymore as of now.

+1
A suggestion as dashboards are longer, can we have auto-scroll as well. Otherwise most of the panels remain hidden on playlist ( on TV )

+1

+1

+1

Any news about this feature?

This is quite amazing that a such work went to the trash.

I have not had time to work on this. I'm also not super familiar with grafana code so if someone else is interested, feel free to take it. If not, I'll take a stab at it when I get time.

+1

+1

+1

@torkelo Any chance of getting this into the upcoming release? It would be super-nice to be able to let the teams rotate their way through all the apps they operate.

@davidkarlsen there is no pull request for this feature and we are in beta so that is very unlikely. Feature requests does not get implemented unless someone works on them, and not aware of anyone working on this.

Ah - I was a bit fast - seems https://github.com/grafana/grafana/pull/2841 got a far way but then was abandoned ;-(

+1

+1

+1

+1

+1

what about using the dashboard PLUS query-string in the playlist?
This would "automatically" add all the vars AND the time-range.

In my example this would be
?orgId=1&var-DATACENTER=dc1&var-FQDN=All&from=now-2d&to=now

what happend...it take almost 4 years and the feature not add master code.....that is so ridiculous

That's a MUST HAVE!

+1

I do not understand why such feature still hasn't been released....

+1

+1

Any progress on this feature? This is a must-have. Without this, playlists are almost as good as useless, at least in my case.

I would also like to see this feature - currently I am having to duplicate dashboards for this

Same as above, I have had to duplicate multiple Screens just to make the playlist usable. This feature would be great.

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

Seeing how much interest this feature has, it's a shame that there is no progress being made.
@costimuraru @utkarshcmu , Do you know the status of this request? Should we consider waiting for this feature, or should we look for alternatives?

Just chiming in to say we'd really like this feature merging too!

I'll give it another try this month!

A workaround if you need to display multiple dashboards with params is to create a html file displaying dashboards in iframes and rotate them with a simple JS script. This is what I use for rotating grafana dashboards on my raspi.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Grafana dashboard rotator</title>

    <style>
        #title {
            position: fixed;
            right: 20px;
            top: 10px;
            color: rgba(255, 0, 0, 0.5);
            background-color: rgba(0, 0, 0, 0.7);
            padding: 10px;
            font-weight: bold;
            font-size: 6em;
            font-family: sans-serif;
            margin: 0;
        }

        body,
        html {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            position: relative;
        }

        iframe {
            width: 100%;
            height: 100%;
            border: 0;
        }

        #timer {
            position: fixed;
            bottom: 10px;
            right: 20px;
            color: rgba(255, 0, 0, 0.5);
            background-color: rgba(0, 0, 0, 0.7);
            padding: 10px;
            font-weight: bold;
            font-size: 2em;
            font-family: sans-serif;
            margin: 0;
        }
    </style>
</head>

<body>

    <h1 id="title"></h1>
    <iframe x-name="SLA PROD EU" src="https://mygrafana.example.com/services-availability?orgId=1&var-ds=Graphite-EU&var-env=prod-eu&var-package=cds-red-bull-high-touch&var-service=All&refresh=30s&from=now-1h&to=now"></iframe>
    <iframe x-name="SLA PROD US" src="https://mygrafana.example.com/services-availability?services-availability?from=now-1h&orgId=1&refresh=30s&to=now&var-ds=Graphite&var-env=prod&var-package=cds-cds&var-service=All"></iframe>
    <iframe x-name="REQUESTS EU" src="https://mygrafana.example.com/services-details?orgId=1&from=now-24h&to=now&var-ds=Graphite-EU&var-env=prod-eu&var-service=All&refresh=30s"></iframe>

    <small id="timer"></small>
    <!-- ROUND ROBIN SCRIPT -->
    <script>

        ; (function (globals) {

            //UMD
            if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
                define([], function () {
                    return rr
                })
            } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
                module.exports = rr
            } else { //script / browser
                globals.rr = rr
            }

            function rr(arr, lastIndex) {
                if (!Array.isArray(arr)) throw new Error("Input is not an array.")
                if (arr.length === 0) return null

                if (arr._rr == null) {
                    arr._rr = 0
                    return arr[0]
                }

                if (arr.length === 1)
                    return arr[0]

                if (typeof lastIndex == 'number')
                    arr._rr = lastIndex

                //is outside of range?
                if (arr._rr >= arr.length - 1 || arr._rr < 0) {
                    arr._rr = 0
                    return arr[0]
                } else {
                    arr._rr += 1
                    return arr[arr._rr]
                }
            }

            rr.splice = function (arr, idx, len) {
                if (!Array.isArray(arr)) throw new Error("Input is not an array.")
                if (arr.length === 0) return

                arr.splice(idx, len);

                if (arr._rr == null) {
                    arr._rr = 0
                    return;
                }

                if (arr._rr >= idx)
                    arr._rr -= 1
            }

            rr.spliceCurrent = function (arr, len) {
                rr.splice(arr, arr._rr, len)
            }

        })(this);
    </script>


    <!-- ROTATOR -->
    <script>
        const interval = 10000; //dashboard switch interval
        const initializingTime = 60000; //initializing time
        const iframes = document.getElementsByTagName('iframe')
        const arr = [...iframes];
        let last = null;

        let count = initializingTime / 1000;
        document.getElementById('title').innerText = `Initializing... (${count}s)`

        const initializingTimer = setInterval(() => {
            count = count > 0 ? count -= 1 : 0;
            document.getElementById('title').innerText = `Initializing... (${count}s)`
        }, 1000)


        let switcherTimer;
        const switcher = () => {
            if (switcherTimer) {
                clearInterval(switcherTimer);
            }

            let count = interval / 1000;
            switcherTimer = setInterval(() => {
                count = count > 0 ? count -= 1 : 0;
                document.getElementById('timer').innerText = `(${count}s)`
            }, 1000)

            const curr = rr(arr)
            curr.scrollIntoView();
            document.getElementById('title').innerText = `${curr.attributes['x-name'].value} (${arr._rr + 1}/${arr.length})`
        }

        setTimeout(() => {
            clearInterval(initializingTimer);

            document.getElementById('title').innerText = `${arr[0].attributes['x-name'].value} (1/${arr.length}) `

            switcher();
            setInterval(switcher, interval)

        }, initializingTime /*give dashboards some time to load*/)

    </script>


    <script>
        //Interval to refresh whole page once per 2 hours. To prevent memory leaks.
        setInterval(() => {
            window.location.reload()
        }, 7200000)
    </script>

</body>

</html>

You can set specific dashboard url in iframe's src attribute.

    <iframe x-name="SLA PROD EU" src="https://mygrafana.example.com/services-availability?orgId=1&var-ds=Graphite-EU&var-env=prod-eu&var-package=cds-red-bull-high-touch&var-service=All&refresh=30s&from=now-1h&to=now"></iframe>

Rotation interval is set in milis in const interval = 10000.
Of course you can add more iframes too.

5 years open, is this code ever going to hit a release?

Was hoping to see this in 6, to be honest.. :)

Another +1, any update on this?

:cake: for the 5 year anniversary of this issue.

Can we get an update?

Hi, it is very important feature, are there any updates on this?

I’m pretty sure this will never happen 😔

I want to use grafana to monitor about 30 servers using one dahboard template.
Without this i have to change 30 templates evrey time I want an update for my template.

This option would be very usefull

:) In the microservice world, it will be so hard to have a dashboard per service .. this option will be very handy and easy to monitor our services instead of having dozens of dashboards just to be able to show them in the playlist .

Would be really useful feature.

+1

+1 - Would be a useful feature

+1

+1

+1; what is the status on this?

+1

+1

+1

+1

+1

+1
This would be very usefull indeed.. sad this request has 5years already

+1

+1 for this.

Also would be good if you could have a hook into Prometheus service discovery so that an $instance could be populated and expanded automatically in the playlist. That way when instances come on / offline they'd be automatically added / removed from the playlist.

This would be very handy feature also for Kiosk mode.

+1

Alguém saberia me dizer se esse recurso foi adicionado?

Was this page helpful?
0 / 5 - 0 ratings