I am trying to figure out the usage of scripted dashboards and came across some great documentation on the docs but couldn’t find an in-depth resource.
For instance, http://docs.grafana.org/reference/dashboard/#panels usage section only describes a graph
panel type and its usage description is missing. How does a table
panel type look like? I would love a pointer (either codebase or godoc type structs or somewhere else) on the usage of different fields in different types of panels.
1 Like
Your best resource is Grafana itself; make a panel similar to what you want in Grafana, then open the panel menu (click the title and select the “three bar” menu) and view the panel JSON. I think the fields are pretty self-explanatory or can be figured out by playing around in the GUI. Here’s a table’s JSON:
{
"id": 1,
"title": "Panel Title",
"span": 12,
"type": "table",
"targets": [
{
"target": "test.foo",
"refId": "A"
}
],
"styles": [
{
"type": "date",
"pattern": "Time",
"dateFormat": "YYYY-MM-DD HH:mm:ss"
},
{
"unit": "short",
"type": "number",
"decimals": 2,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"colorMode": null,
"pattern": "/.*/",
"thresholds": []
}
],
"transform": "timeseries_to_rows",
"pageSize": null,
"showHeader": true,
"columns": [],
"scroll": true,
"fontSize": "100%",
"sort": {
"col": 0,
"desc": true
},
"filterNull": false
}
2 Likes
This is a great start and does give a good feel, thanks! I am curious how datasource queries are represented in the panels. My best guess is the targets
field, but what syntax does it use? Is there any documentation on the associated query syntax for each supported data source?
If I wanted to add a custom data source for each panel, what field would it go to? While I suppose I can try out each permutation of my curiosity and see the generated JSON, it would be great (and possibly easier) to look at the relevant parts of the codebase or any reference doc that covers the topic.
Yes, the queries are in the targets
field, the format therein varies by datasource. There may be documentation, I haven’t looked lately… I just explore by making dashboards, occasionally looking into the code… it’s all on GitHub https://github.com/grafana/grafana - you’ll either want datasource or dashboard I guess.
I’m not sure what you mean by the “custom data source for each panel”… data sources have to be configured outside the dashboard.
1 Like
I think I remember reading it somewhere that a Grafana dashboard can be
composed of panels that tie to different data source. That’s not possible?
Thanks for the codebase pointers.
Oh yeah, definitely, the datasource
field controls that. You can even use multiple datasources in the same panel!
Hi,
Thanks in advance,
Do you have any documentation to do the same with Influx db ??(Scripted dashboard with influx )
- How to use quaries in targets
- How to create different panels.
Hi,
Thanks in advance,
Do you have any documentation to do the same with Influx db ??(Scripted dashboard with influx )
- How to use quaries in targets
- How to create different panels.
Again, just make a similar panel using the datasource you want in the Grafana UI then copy/paste the JSON.