2016-10-21 17:01:34 +08:00
+++
2020-10-02 05:13:39 +08:00
title = "Scripted dashboards"
2016-10-21 17:01:34 +08:00
keywords = ["grafana", "dashboard", "documentation", "scripted"]
2020-10-02 05:13:39 +08:00
aliases = ["/docs/grafana/latest/reference/scripting/"]
weight = 1500
2016-10-21 17:01:34 +08:00
+++
2020-10-02 05:13:39 +08:00
# Scripted dashboards
2015-03-10 15:55:42 +08:00
2020-10-02 05:13:39 +08:00
> **Warning:** This feature is deprecated and will be removed in a future release.
2015-03-10 15:55:42 +08:00
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.
2020-10-14 13:53:06 +08:00
With scripted dashboards you can dynamically create your dashboards using javascript. In the Grafana install folder
2020-02-15 00:11:08 +08:00
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:
2015-04-13 20:12:03 +08:00
`http://grafana_url/dashboard/script/scripted.js?rows=3&name=myName`
2015-03-10 15:55:42 +08:00
2020-02-15 00:11:08 +08:00
If you open scripted.js you can see how it reads URL parameters from ARGS variable and then adds rows and panels.
2015-03-10 15:55:42 +08:00
## Example
```javascript
var seriesName = 'argName';
2020-04-30 00:24:26 +08:00
if (!_.isUndefined(ARGS.name)) {
2015-03-10 15:55:42 +08:00
seriesName = ARGS.name;
}
2018-06-30 01:30:29 +08:00
dashboard.panels.push({
title: 'Events',
type: 'graph',
fill: 1,
linewidth: 2,
gridPos: {
h: 10,
w: 24,
x: 0,
y: 10,
},
targets: [
{
2020-04-30 00:24:26 +08:00
target: "randomWalk('" + seriesName + "')",
2018-06-30 01:30:29 +08:00
},
{
2020-04-30 00:24:26 +08:00
target: "randomWalk('random walk2')",
},
],
2018-06-30 01:30:29 +08:00
});
2015-03-10 15:55:42 +08:00
return dashboard;
```
## More examples
2020-10-14 13:52:35 +08:00
You can find more examples in `public/dashboards/` directory of your Grafana installation.