grafanalib
grafanalib copied to clipboard
Expose all options supported by grafana
What you expected to happen?
I should be able to set any grafana supported option.
What happened?
When setting an option, e.g., colorMode
for a BarGauge
, I get the error,
TypeError: __init__() got an unexpected keyword argument 'colorMode'
I'm sure there are other supported options currently not exposed as well.
Grafana json
{
"id": 3,
"gridPos": {
"x": 16,
"y": 0,
"w": 8,
"h": 7
},
"type": "bargauge",
"title": "Daily Average By Pod",
"transformations": [],
"pluginVersion": "8.4.0-pre",
"maxDataPoints": 100,
"interval": "30s",
"links": [],
"cacheTimeout": null,
"description": null,
"editable": true,
"error": false,
"height": null,
"hideTimeOverride": false,
"maxPerRow": null,
"options": {
"reduceOptions": {
"values": false,
"calcs": [
"lastNotNull"
],
"fields": "",
"limit": null
},
"orientation": "horizontal",
"displayMode": "gradient",
"showUnfilled": true,
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"repeat": null,
"repeatDirection": null,
"targets": [
{
"datasource": null,
"expr": "avg_over_time(sum by (database) (metric1)[5m:5m])",
"format": "time_series",
"hide": false,
"instant": false,
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{instance}}/{{app}}/{{database}}",
"metric": "",
"refId": "A",
"step": 10,
"target": ""
}
],
"timeFrom": null,
"timeShift": null,
"fieldConfig": {
"defaults": {
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "purple",
"index": 0,
"line": true,
"op": "gt",
"value": null,
"yaxis": "left"
}
]
},
"mappings": [],
"decimals": null,
"links": [],
"max": null,
"min": 0,
"unit": "none",
"color": {
"mode": "continuous-BlPu"
}
},
"overrides": []
},
"datasource": null
}
re: #439
I think a good start to implementing this would be creating JSONSchema for each graph. Grafana has one for the dashboard, but I don't see anything for the graphs.
There is an OpenApi spec in the grafonnet repository: https://github.com/grafana/dashboard-spec/tree/master/specs/7.0 Maybe grafanalib can use some automatic/semi-automatic approach to generate basic Python object representation from OpenApi spec...