this charm requires dashboard json files to nest data under key `dashboard` by mistake
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Grafana Charm |
Fix Released
|
High
|
Joe Guo |
Bug Description
this charm requires dashboard json files to nest data under key `dashboard` by mistake
According to grafana JSON model doc[0], dashboard JSON is supposed to be in following format:
{
"id": null,
"uid": "cLV5GDCkz",
"title": "New dashboard",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"graphTooltip": 1,
"panels": [...],
...
}
All the dashboard json files you can download from official website https:/
However, in function `lib/charms/
def import_
...
)
if name is None:
name = dashboard[
return post_dashboard(
It's assuming the dashboard JSON nests data under key `dashboard`.
This function is used by both the dashboard relation and `import-dashboard` action.
And most of the dashboard json files in our charms follow that requirement, to comply with grafana-charm.
It seems this mistake is caused by a misread of grafana rest api[1]:
it does requires data to be wrapped under key `dashboard`:
{
"dashboard": {
"id": 104,
"panels": [...],
...
},
"overwrite": true,
"folderId": "xxx",
...
}
But that's for rest api request only, not meant for json file content.
The consequences of this bug:
dashboard json files in our charms are not compatible with official ones, we have a extra `dashboard` wrapper
if we try to import a correct/official dashboard, we will get keyerror in log:
tracer: ++ queue handler reactive/
unit-grafana-0: 09:57:15 INFO unit.grafana/
unit-grafana-0: 09:57:15 INFO unit.grafana/
unit-grafana-0: 09:57:18 INFO unit.grafana/
unit-grafana-0: 09:57:19 DEBUG unit.grafana/
unit-grafana-0: 09:57:19 DEBUG unit.grafana/
unit-grafana-0: 09:57:19 DEBUG unit.grafana/
unit-grafana-0: 09:57:19 DEBUG unit.grafana/
unit-grafana-0: 09:57:19 DEBUG unit.grafana/
unit-grafana-0: 09:57:19 DEBUG unit.grafana/
unit-prometheus2-0: 09:57:29 INFO unit.prometheus
unit-prometheus2-0: 09:57:29 DEBUG unit.prometheus
tracer: set flag config.
[0]: https:/
[1]: https:/
Related branches
- Adam Dyess (community): Approve
- James Hebden (community): Approve
-
Diff: 63 lines (+27/-8)2 files modifiedsrc/lib/charms/layer/grafana.py (+26/-8)
src/wheelhouse.txt (+1/-0)
Changed in charm-grafana: | |
importance: | Undecided → High |
Changed in charm-grafana: | |
status: | New → In Progress |
assignee: | nobody → Joe Guo (guoqiao) |
Changed in charm-grafana: | |
milestone: | none → 20.10 |
status: | In Progress → Fix Committed |
Changed in charm-grafana: | |
status: | Fix Committed → Fix Released |