Scripted dashboards

Warning: This feature is deprecated and will be removed in a future release.

If you have lots of metric names that change (new servers etc) in a defined pattern it is irritating to constantly have to create new dashboards.

With scripted dashboards you can dynamically create your dashboards using javascript. In the Grafana install folder under public/dashboards/ there is a file named scripted.js. This file contains an example of a scripted dashboard. You can access it by using the URL: http://grafana_url/dashboard/script/scripted.js?rows=3&name=myName

If you open scripted.js you can see how it reads URL parameters from ARGS variable and then adds rows and panels.

Example

  1. var seriesName = 'argName';
  2. if (!_.isUndefined(ARGS.name)) {
  3. seriesName = ARGS.name;
  4. }
  5. dashboard.panels.push({
  6. title: 'Events',
  7. type: 'graph',
  8. fill: 1,
  9. linewidth: 2,
  10. gridPos: {
  11. h: 10,
  12. w: 24,
  13. x: 0,
  14. y: 10,
  15. },
  16. targets: [
  17. {
  18. target: "randomWalk('" + seriesName + "')",
  19. },
  20. {
  21. target: "randomWalk('random walk2')",
  22. },
  23. ],
  24. });
  25. return dashboard;

More examples

You can find more examples in public/dashboards/ directory of your Grafana installation.