Template update variable API


Is there a way to refresh templates out-of-band?
I have a template which takes a long time to load, and I don’t want this to happen every time ppl hit F5
but I don’t want to set the refresh to “never” either
so I was thinking setting up a cronjob or something
in other words: is there an API call for refreshing a template query?


no, there is no api call as this template variable values are cached inside the dashboard json.

You could set it to never and have a phantomjs script open dashboard, update the variable and save at regular intervals.

thanks. In my opinion/experience this sounds a bit too complex especially as I’d need to authenticate the bot and develop quite some tooling around it (parsing output, etc.)


I guess I could modify the JSON in the database directly, but this sounds very intricate too :-/
I really think an API call would make sense. I’ll look into the code to see if it’s hard to do.

You could change the Template Variable to be type Custom and hardcode the variables (comma separated list) and then update the variable in the dashboard json via the Grafana API: http://docs.grafana.org/http_api/dashboard/#create-update-dashboard

1 Like