Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating larger dashboards for Grafana >=5 #116

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

Comments

@0x63lv
Copy link
Contributor

@0x63lv 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

This comment has been minimized.

Copy link
Collaborator

@roidelapluie roidelapluie commented Mar 25, 2019

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

@0x63lv

This comment has been minimized.

Copy link
Contributor Author

@0x63lv 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 Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.