Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Generating larger dashboards for Grafana >=5 #116

Closed
0x63lv opened this issue Mar 25, 2019 · 2 comments
Closed

Generating larger dashboards for Grafana >=5 #116

0x63lv opened this issue Mar 25, 2019 · 2 comments

Comments

@0x63lv
Copy link
Contributor

0x63lv commented Mar 25, 2019

It appears that grafonnet-lib has an issue when generating larger dashboards without the row elements for Grafana 5 and 6.

As the jsonnet source file becomes larger (e.g. more addPanel fields), the jsonnet execution time gets increasingly slower, up to a point of it apparently hanging wile using all of the CPU until interrupted.

Used Grafana 5 example dashboard from the Readme as a test case.

# As-is from the Readme (some addTemplate blocks and 1 addPanel)
$> time jsonnet -J /path/to/grafonnet-lib example.jsonnet -o example.json
real	0m0.179s
user	0m0.163s
sys	0m0.014s

# With 15 addPanel blocks copy/pasted
real	0m2.439s
user	0m2.406s
sys	0m0.021s

# With 20 addPanel blocks
real	1m38.843s
user	1m36.830s
sys	0m0.267s

# With 30 addPanel blocks
(interrupted after)
real	3m59.107s
user	3m52.272s
sys	0m0.766s

Strangely, this issue is not evident, if enclosing all of these addPanel fields in an addRow field:

# Same 30 addPanels, but inside an addRow:
$> time jsonnet -J /path/to/grafonnet-lib example.jsonnet -o example.json
real	0m0.268s
user	0m0.240s
sys	0m0.018s

Using addRow, however, does not really fix anything. The row implementation changed in Grafana 5 with the introduction of "flexible grid". It appears that grafonnet-lib would still generate pre-Grafana 5 row structure (even with schemaVersion >=16), which cannot be properly imported into Grafana 5/6. When using schemaVersion <16, the resulting dashboard, when imported, does not take into account the specified gridPos directives.

Is this an issue with my approach or grafonnet-lib itself?

@roidelapluie
Copy link
Collaborator

roidelapluie commented Mar 25, 2019

Please use addPanels and not addPanel; it is much more efficient.

@0x63lv
Copy link
Contributor Author

0x63lv commented Mar 26, 2019

Was not aware such a construct exists. It indeed goes much faster if I use it. Thanks.

@0x63lv 0x63lv closed this as completed Mar 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants